*** 作步骤如下:
1、首先我们在这个StudentNo列上用你的鼠标右击,然后选择里面的修改,进行点击,d出
界面。
2、接着会有如下图中所示的窗口内容,这里选择里面的StudentNo,然后右击选择设置主键。
3、设置完毕之后,选择ctrl + S 保存。
4、保存完毕之后,再查看设置的主键时候,没有显示设置成功,这里需要在表上右击,选择刷
新。
5、刷新之后,就可以看到你设置的主键了,在主键列表中也可以看到已将设置成功。
先执行:alter table 表名
alter column 列名1 int not null
再执行:
alter table 表名 add constraint PK_主键约束 primary key (列名1)
执行第一句前提是表中的“列名1”列没有空值才可以。
例如:
alter table testtab alter column testid int not null
alter table testtab add constraint PrimaryKey primary key (testid)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)