开发者

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

开发者 https://www.devze.com 2023-02-19 20:30 出处:网络
hello all i have problem with mysql...i have fielduser can save value in it or leave it empt开发者_如何学Cy so should i set default value for this field NULL? isnt it...ok how i do it?That is the defa

hello all i have problem with mysql...i have field user can save value in it or leave it empt开发者_如何学Cy so should i set default value for this field 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.


There is no need for a field to be NULL, yuo can just enter an empty value. This is often better as NULL means "no information present" not "field empty". A user might intentionally leave a field empty because he has nothing to fill it with (e.g. "personal website") but this IS an information, while NULL means "we don't know".

0

精彩评论

暂无评论...
验证码 换一张
取 消