将DEFAULT添加到现有列


Answers:


16
ALTER TABLE yourTable ADD  CONSTRAINT constraintName  
   DEFAULT ('XYZ') FOR [YourColumn]

要更改默认值,请删除约束,然后将其重新添加为新值:

ALTER TABLE yourTable
DROP CONSTRAINT constraintName

ALTER TABLE yourTable ADD  CONSTRAINT constraintName  
   DEFAULT ('ABC') FOR [YourColumn]

也可以在设计器中完成。
SqlSandwiches 2011年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.