当前位置: 代码迷 >> Sql Server >> 在已经存在的表添加一个ID,自增号。该如何解决
  详细解决方案

在已经存在的表添加一个ID,自增号。该如何解决

热度:75   发布时间:2016-04-27 12:39:54.0
在已经存在的表添加一个ID,自增号。
ACCESS里面都有这个功能。自增ID
从1,开始,每新建一条记录就增加一个ID,请问怎么建立呢?

------解决方案--------------------
alter table 你的表的名字 add 字段名字 int identity
------解决方案--------------------
create table tb
(
id int identity(1,1)
)
------解决方案--------------------
探讨

create table tb
(
id int identity(1,1)
)

------解决方案--------------------
楼主描述的是针对一个已经存在的表(字段),如何去加这个identity
------解决方案--------------------
declare @tab table(int id identity(1,1))
------解决方案--------------------
alter table 表 add 字段名字 int identity
------解决方案--------------------
SQL code
alter table tb add id bingint identity(1,1)
------解决方案--------------------
SQL code
create table tb(id int identity(1,1) )
  相关解决方案