Create table: default value for column
/*
mysql> Drop table Books;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE Books
-> (
-> ID SMALLINT NOT NULL,
-> Name VARCHAR(40) NOT NULL,
-> PubID SMALLINT NOT NULL DEFAULT 'Unknown'
-> )
-> ENGINE=INNODB;
Query OK, 0 rows affected (0.09 sec)
mysql> Describe Books;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| ID | smallint(6) | | | 0 | |
| Name | varchar(40) | | | | |
| PubID | smallint(6) | | | 0 | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
*/
Drop table Books;
CREATE TABLE Books
(
ID SMALLINT NOT NULL,
Name VARCHAR(40) NOT NULL,
PubID SMALLINT NOT NULL DEFAULT 'Unknown'
)
ENGINE=INNODB;
Describe Books;
Related examples in the same category