SQL server增删改查

发布时间 2023-04-03 16:30:05作者: 水向东流时间怎么偷
1、添加字段
alter table 表名 add 字段名 type not null default 0
2、修改字段名
alter table 表名 rename column A to B
3、修改字段类型
alter table 表名 alter column UnitPrice decimal(18, 4) not null
4、修改字段默认值
alter table 表名 drop constraint 约束名字   ------说明:删除表的字段的原有约束
alter table 表名 add constraint 约束名字 DEFAULT 默认值 for 字段名称 -------说明:添加一个表的字段的约束并指定默认值
5、删除字段
alter table 表名 drop column 字段名;
————————————————
版权声明:本文为CSDN博主「tomstars」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/tomstars/article/details/82014110