跳转至

SQLServer

基础命令

# 给已有的表增加联合主键
# 先设置非空约束
Alter table t_dept alter column dept_id int not null
Alter table t_dept alter column dept_name varchar(20) not null
# 增加主键
Alter table t_dept add constraint pk_t_dept primary key(dept_id, dept_name)