Mega Code Archive

 
Categories / MySQL Tutorial / Data Types
 

Use SMALLINT column as the primary key column

mysql> mysql> CREATE TABLE myTable     -> (     ->    ID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,     ->    Description VARCHAR(40)     -> ); Query OK, 0 rows affected (0.03 sec) mysql> mysql> desc myTable; +-------------+----------------------+------+-----+---------+-------+ | Field       | Type                 | Null | Key | Default | Extra | +-------------+----------------------+------+-----+---------+-------+ | ID          | smallint(5) unsigned | NO   | PRI |         |       | | Description | varchar(40)          | YES  |     | NULL    |       | +-------------+----------------------+------+-----+---------+-------+ 2 rows in set (0.01 sec) mysql> mysql> drop table myTable; Query OK, 0 rows affected (0.00 sec)