Igor Parra
Igor Parra

Reputation: 10348

Default values for varchar and int mysql data types

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?

enter image description here

Upvotes: 10

Views: 24997

Answers (1)

None
None

Reputation: 5649

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.

Upvotes: 12

Related Questions