简体   繁体   English

我如何在mysql字段中将默认值设置为NULL

[英]how i can set default value in mysql field to be NULL

hello all i have problem with mysql...i have field user can save value in it or leave it empty so should i set default value for this field NULL? 您好,我在使用mysql时都遇到问题...我有字段用户可以在其中保存值或将其保留为空,因此我应该为此字段设置默认值NULL吗? isnt it...ok how i do it? 是不是...我该怎么做?

That is the default value in most cases. 在大多数情况下,这默认值。 Just don't specify a default and of course don't specify NOT NULL for that field when defining the table schema. 只是不要指定默认值,当然在定义表模式时不要为该字段指定NOT NULL。

There is no need for a field to be NULL, yuo can just enter an empty value. 无需将字段设置为NULL,您只需输入一个空值即可。 This is often better as NULL means "no information present" not "field empty". 这通常会更好,因为NULL表示“无信息”而不是“字段为空”。 A user might intentionally leave a field empty because he has nothing to fill it with (eg "personal website") but this IS an information, while NULL means "we don't know". 用户可能有意将字段留空,因为他没有什么可填写的(例如“个人网站”),但这只是一种信息,而NULL表示“我们不知道”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM