Introduction and example usage of default in mysql
This article introduces the relevant knowledge of "introduction and example usage of default in mysql". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. It is used to set the default value of the column. If no value is assigned to a field, the system automatically inserts the default value for the field.
No assignment means that when insert inserts data, the field is not specified.
2. If a null value is specified, the final stored value is null.
Example
Mysql > create table user (age int (11) default 18); Query OK, 0 rows affected, 1 warning (0.05 sec) mysql > insert user values (); Query OK, 1 row affected (0.02 sec) mysql > select * from user;+-+ | age | +-+ | 18 | +-+ 1 row in set (0.00 sec) "introduction and example usage of default in mysql" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!