新建表
create table shujubiao (ID int primary key not null, name varchar(10) not null, age int null )
修改表结构
修改name的字段类型长度
alter table shujubiao alter column name varchar(100);
修改字段类型
alter table shujubiao alter column age float;
添加not null约束
alter table shujubiao alter column age float not null;
设置主键
alter table shujubiao add constraint KID primary key (ID);
更改字段名
exec sp_rename ‘shujubiao.age’,’userage’,’column’;
添加字段名
alter table shujubiao add grade varchar(10) not null
删除表
drop table shujubiao;
定义外键
alter table shujubiao add constraint FK_shujubiao foreign key(age) references qitashujubiao(userage);
