Default values for varchar and int mysql data types

杀马特。学长 韩版系。学妹 提交于 2019-12-13 12:06:05

问题


The screenshot show 3 typical definitions of data type: id (autoincrement), a title and a number.

1.- Which are differences between: none and NULL?
2.- Do I must choose as defined: '' for varchar types when I want an empty string?
3.- Do I must put an as defined: 0 default value for autoincrement int types?


回答1:


Default none means there is no default value. If a value is not provided on an insert, the query will fail with a "no default value error".

NULL is the actual NULL value meaning if no value is provided on an insert the column will default to NULL (empty). For varchar you can set default to '', but NULL is better.

Autoincrement int types shouldn't have a default value (Default: None) because it will always have a value.



来源:https://stackoverflow.com/questions/10605327/default-values-for-varchar-and-int-mysql-data-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!