您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Sql Server代码设置主键并自动生长

2025/11/7 12:38:02发布26次查看
新建一张数据表,将userid设为主键并自动增长 create table t_userlogin(userid int not null primary key identity(1,1),username nvarchar(50) not null,pass varchar(50) not null ) 修改已经建好的一张数据表,将userid设为主键并自动生长 alter table t
新建一张数据表,将userid设为主键并自动增长
create table t_userlogin(userid int not null primary key identity(1,1),username nvarchar(50) not null,pass varchar(50) not null )
修改已经建好的一张数据表,,将userid设为主键并自动生长
alter table tb alter column id int not null
alter table tb add constraint pkid primary key (id)
删除主键
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)
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product