大荔同州中学,matthew james moy,邪恶力量第一季爱奇艺
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
如果字段有默认值,则需要先删除字段的约束,在添加新的默认值,
select c.name from sysconstraints a
inner join syscolumns b on a.colid=b.colid
inner join sysobjects c on a.constid=c.id
where a.id=object_id('表名')
and b.name='字段名'
根据约束名称删除约束
alter table 表名 drop constraint 约束名
根据表名向字段中增加新的默认值
alter table 表名 add default (0) for 字段名 with values
4、增加字段:
alter table 表名 add 字段名 type not null default 0
5、删除字段:
alter table 表名drop column 字段名;
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
SQL Server免费版的安装以及使用SQL Server Management Studio(SSMS)连接数据库的图文方法
SQL Server 2017 Developer的下载、安装、配置及SSMS的下载安装配置(图文教程详解)
网友评论