
列可以包含空值;
或者列具有指定的 default 定义;
或者要添加的列是标识列或时间戳列;
或者,如果前几个条件均未满足,则表必须为空以允许添加此列。
下面:表名是 "table1",以下方法都可以插入一个非空列
方法一:
alter table table1
add BZ nvarchar(50) not null
方法二:
alter table table1
add BZ nvarchar(50) not null default('默认值')
方法三:
alter table table1
add BZ int identity(1,1) not null
希望对你有所帮助!
alert table TableName add FieldName varchar(100) not null改成
alter table TableName add FieldName varchar(100) not null
我自己测试过了。。
alert table TableName add FieldName varchar(100) not null
是可以创建列的
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)