重新安排数据表

编程入门 行业动态 更新时间:2024-10-18 21:19:58
本文介绍了重新安排数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好, 我有问题.. 我正在使用Visual Studio 2008和ms sql server创建基于c# Windows的项目. 我想在删除后重新排列我的数据表. 我正在解释... (1)我有一张州代码表,州名,年份. 如果我从所有状态中删除1个状态,则应重新排列状态代码. 就像状态码1,2,3,4,5.和我删除第4行,则它变成1,2,3,5. 我希望它是1,2,3,4.means从1开始的4条记录. (2)如果我不将状态码用作主键,那么是什么 解决此问题的方法. 请回复.

hello, i have a problem.. i am creating c# windows based project using visual studio 2008 and ms sql server. i want to rearrange my datatable after deletion. i am explaining it... (1) i have a table of Statecode,statename,year. if i delete 1 state from all states,then statecode should be re-arrange. as if statecode 1,2,3,4,5.and i delete 4th row then it becomes 1,2,3,5. i want it to be 1,2,3,4.means 4 records starting from 1. (2) if i will not take statecode as a primary key,then what is the solution for this problem. please reply.

推荐答案

khandelwal g写道: khandelwal g wrote:

我希望它成为1 ,2,3,4.表示从1

i want it to be 1,2,3,4.means 4 records starting from 1

开始的4条记录 你为什么要这么做?有什么需要吗?不建议这样做.通常,应用程序不适用于单个表.有依赖关系和外键关系.如果更改主表中的从属列值,则还需要注意其他表. 重新分配值没有意义.它们在数据库中,您的应用程序知道如何处理它. 实际上,大多数时候,主键都被用作身份键,以避免出现任何问题.

Why do you want to do that? What''s the need? It''s not advisable. Generally applications does not work on single table. There are dependencies and foreign key relations. If you change a dependant column value in main table then you need to take care of other tables too. There is no point in re-assigning the values. They are in DB and your application knows how to handle it. Infact, primary keys most of the times are made an Identity Key to avoid any issue.

khandelwal g写道: khandelwal g wrote:

如果我不将状态码用作主键,那么什么是 解决此问题的方法.

if i will not take statecode as a primary key,then what is the solution for this problem.

我在这里没发现任何问题吗?麻烦您什么了?重新排列不会帮助您,为什么要这么做!

I don''t find any problem out here? What''s troubling you? Rearrangement is not going to help you, so why to do it!

更多推荐

重新安排数据表

本文发布于:2023-07-14 09:59:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104034.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!