34,591
社区成员
发帖
与我相关
我的任务
分享
alter table tablename alter column columnname set default 'value'
alter table tb drop XXOO
alter table tb add constraint XXOO default 'xoxo' for oo
alter table tb add constraint XXOO default 'xx' for oo
--就是加了一个约束,默认值也是一种约束
if object_id('tb','U') is not null
drop table tb
go
create table tb
(
id int identity(1,1),
name varchar(10)
)
go
alter table tb add constraint tb_name_def default 'abc' for name
Create table tablename(columnname nvarchar(50))
go
alter table tablename add constraint UQ_tablenam_columnname default 'value' for columnname;
alter table tablename alter column columnname default 'value'