SQL 使用 DEFAULT Empty String 避免 NULL 列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3421659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Avoid NULL columns using DEFAULT Empty String
提问by GibboK
how can I create a Column with the default value being an empty string?
如何创建一个默认值为空字符串的列?
thanks guys!
谢谢你们!
回答by Lieven Keersmaekers
回答by tdammers
Something like:
就像是:
CREATE TABLE foobar (string_column VARCHAR(100) NOT NULL DEFAULT '')
CREATE TABLE foobar (string_column VARCHAR(100) NOT NULL DEFAULT '')
回答by Reza Roshan
In SQL server you can set "Column properties > Default value or binding" section to ('')
. NOTE: It includes single quotation and parenthesis
在 SQL Server 中,您可以将“列属性 > 默认值或绑定”部分设置为('')
. 注意:包括单引号和括号