在现有数据库中添加标识列 [英] Add a identity column in existing database

查看:196
本文介绍了在现有数据库中添加标识列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我有一张包含大约7000多种数据的表格。



现在我想要在现有数据上添加唯一的id列,以后如果用户添加

任何记录,它应该自动增加。



例如以下是现有数据



Hi all

I have a table which contains around 7000+ data.

now i want to add a unique id column on the existing data and also later if user adds
any records, it should increment automatically.

e.g. Below is the existing data

1    name    54
1    name    50
2    age     88
3    place   12....





我想要这样





and i want like this

00001   1    name    54
00002   1    name    50
00003   2    age     88
00004   3    place   12....





请告诉我怎么做这个



对不起,我做了一个错误的标签。

我在谷歌搜索,我得到了一个名为serial的自动增量ID,这符合我的目的。



但有一件事我希望这个数字像这样开始 - 00000000001等等。



Please tell me how to do this

I am sorry, i made a wrong tag.
I search in google and i got something called "serial" for auto-increment id which serves my purpose.

But one thing i want the number to start like this-"00000000001" and so on.

推荐答案

您没有提供有关您的问题的足够信息。因此,我认为最困难的是创建自定义自动生成序列,例如: 00001



请按照下列步骤操作: http://www.sqlteam.com/article/custom -auto-generated-sequences-with-sql-server [ ^ ]
You did not provide enough information about your issue. So, i assume that the most difficult to you is to create custom autogenerated sequence, for example: 00001.

Follow these steps: http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server[^]


这篇关于在现有数据库中添加标识列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆