开发者

mysql default value?

In my database, is it standard to开发者_开发问答 leave most fields with default value "none"? For example a user id, a post title, category, or tags.


For required fields such as username or password, you should set NOT NULL. For other optional fields you can set it to NULL. For numbers, it is almost always a good idea to set default value to zero 0 .


I'll answer your question as I best understand it.

For User_id, it is common to set its default value to auto_increment. SQL will automatically fill this in when you create a new record.

Text fields will default to null, although when you create the table you can set a DEFAULT such as ' ', 'cat' or anything else you like.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜