1.创建表
create table test_tb1(
Id int not null,
Name varchar(50) not null,
Sex char(4) null
);
2.添加列
alter table test_tb1
add No int null
3.修改列
alter table test_tb1
alter column No int not null
4.删除列
alter table test_tb1
drop column No;
5.添加主键约束
alter table test_tb1
add constraint pk_unit primary key(Id)
6.列重命名
--列重命名
EXEC sp_rename 'test_tb1.No', 'Number', 'COLUMN';
7.添加外键
create table test_tb2(
Id int not null,
tb1Id int foreign key references test_tb1(Id)
)