sqlserver 增刪改字段

1、添加字段

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

2、修改字段名

alter table 表名 rename column A to B

3、修改字段類型

alter table 表名 modify column UnitPrice decimal(18, 4) not null 

4、修改字段默認值

alter table 表名 drop constraint 約束名字   ------說明:刪除表的字段的原有約束

alter table 表名 add constraint 約束名字 DEFAULT 默認值 for 字段名稱 -------說明:添加一個表的字段的約束並指定默認值

5、刪除字段

alter table 表名 drop column 字段名;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章