Create table: not null and default value
/*
mysql> Drop table Product;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE Product
-> (
-> ID SMALLINT UNSIGNED NOT NULL,
-> Name VARCHAR(40) NOT NULL
-> );
Query OK, 0 rows affected (0.05 sec)
mysql> Describe Product;
+-------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------------------+------+-----+---------+-------+
| ID | smallint(5) unsigned | | | 0 | |
| Name | varchar(40) | | | | |
+-------+----------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
*/
Drop table Employee;
CREATE TABLE Employee
(
ID SMALLINT UNSIGNED NOT NULL,
YearBorn YEAR NOT NULL,
CityBorn VARCHAR(40) NOT NULL DEFAULT 'Unknown'
);
Describe Employee;
Related examples in the same category