最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SQL Server設置主鍵自增長列(使用sql語句實現(xiàn))

 更新時間:2013年01月24日 16:47:53   作者:  
主鍵自增長列在進行數(shù)據(jù)插入的時候,很有用的,如可以獲取返回的自增ID值,接下來將介紹SQL Server如何設置主鍵自增長列,感興趣的朋友可以了解下,希望本文對你有所幫助
1.新建一數(shù)據(jù)表,里面有字段id,將id設為為主鍵
復制代碼 代碼如下:

create table tb(id int,constraint pkid primary key (id))
create table tb(id int primary key )

2.新建一數(shù)據(jù)表,里面有字段id,將id設為主鍵且自動編號
復制代碼 代碼如下:

create table tb(id int identity(1,1),constraint pkid primary key (id))
create table tb(id int identity(1,1) primary key )

3.已經(jīng)建好一數(shù)據(jù)表,里面有字段id,將id設為主鍵
復制代碼 代碼如下:

alter table tb alter column id int not null
alter table tb add constraint pkid primary key (id)

4.刪除主鍵
復制代碼 代碼如下:

Declare @Pk varChar(100);
Select @Pk=Name from sysobjects where Parent_Obj=OBJECT_ID('tb') and xtype='PK';
if @Pk is not null
exec('Alter table tb Drop '+ @Pk)

相關文章

最新評論

巢湖市| 白山市| 黔东| 麦盖提县| 札达县| 平潭县| 满洲里市| 大庆市| 新巴尔虎左旗| 灵宝市| 偃师市| 泸水县| 阿克| 金坛市| 台南市| 肥东县| 扎兰屯市| 贡觉县| 广德县| 霍城县| 乡城县| 饶河县| 隆回县| 襄樊市| 武城县| 余江县| 城市| 含山县| 左贡县| 沁水县| 望城县| 石屏县| 曲阳县| 泉州市| 老河口市| 邢台县| 乐平市| 竹溪县| 吉林市| 樟树市| 汉川市|