Sql添加/删除默认值

1.添加字段的时候添加默认值

alter table [Student]
add [Sex] bit not null default '1'

 2.已存在字段添加默认值

alter table  [Student]
add default '1'  for [Sex]
with values

3.已存在默认值新建默认值

alter  table [Student]  drop column [Sex]     --先删除,此时会报错


--找到默认值的名称,并删除
ALTER TABLE [student]
DROP DF__student__sex__34C8D9D1;


--最后重新添加默认值

 

posted @ 2021-09-28 15:12  RookieCoderAdu  阅读(676)  评论(0编辑  收藏  举报