sql 修改字段

1、修改字段名:

  alter table 表名 rename column A to B

2、修改字段类型:

  alter table 表名 alter column 字段名 type not null

3、修改字段默认值(如果字段有默认值,则需要先删除字段的约束,在添加新的默认值)
  alter table 表名 add default (0) for 字段名 with values 

  根据约束名称删除约束

  alter table 表名 drop constraint 约束名

4、增加字段:

  alter table 表名 add 字段名 type not null default 0

5、删除字段:

  alter table 表名 drop column 字段名;

转自:https://www.cnblogs.com/pangpanghuan/p/6432331.html

非常感谢

 

你可能感兴趣的:(sqlserver)