Set column default value for VARCHAR : Char Varchar : Data Types MySQL TUTORIALS


MySQL TUTORIALS » Data Types » Char Varchar »

 

Set column default value for VARCHAR


mysql>
mysql> CREATE TABLE myTable
    -> (
    ->    ID SMALLINT UNSIGNED NOT NULL,
    ->    Year YEAR NOT NULL,
    ->    City VARCHAR(40NOT NULL DEFAULT 'Unknown'
    -> )
    -> ENGINE=INNODB;
Query OK, rows affected (0.08 sec)

mysql>
mysql> desc myTable;
+-------+----------------------+------+-----+---------+-------+
| Field | Type                 | Null | Key | Default | Extra |
+-------+----------------------+------+-----+---------+-------+
| ID    | smallint(5unsigned | NO   |     |         |       |
| Year  | year(4)              | NO   |     |         |       |
| City  | varchar(40)          | NO   |     | Unknown |       |
+-------+----------------------+------+-----+---------+-------+
rows in set (0.00 sec)

mysql>
mysql> drop table myTable;
Query OK, rows affected (0.03 sec)



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Data Types
» Char Varchar