definition:
"The default value (Default)" complete call "default value constraints (Default Constraint)". MySQL Default constraints specify default values for a column. No assignment for this field if a new record is inserted, then the system will automatically assign default values in this field.
Set Default
1, set the default value when you create a table
The syntax rules are as follows:
<Field name> <data type> the DEFAULT <Default>;
[Example 1] create a data table tb_dept3, specify the location defaults to Beijing
After the above statement is executed successfully, the field location on the table tb_dept3 have a default value of Beijing, the newly inserted record location if not specified, it defaults are Beijing.
2, was added when the modified default value table
The syntax rules are as follows:
ALTER TABLE <table name>
CHANGE [COLUMN] <field name> <field name> <data type> the DEFAULT <Default>;
Remove the default value
The syntax rules are as follows:
ALTER TABLE <table name>
CHANGE [COLUMN] <field name>
<Field name> <field type> DEFAULT NULL;
[Example 3] to modify the data table tb_dept3, will remove the location of the default value constraints