mysql默认值?

问题描述:

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.

在我的数据库中,保留大多数默认值为“none”的字段是否标准? 例如,用户ID,帖子标题,类别或标签。 p> div>

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.