Mega Code Archive

 
Categories / MySQL / Table Index
 

Create index on a column

/* mysql> Drop table Product; Query OK, 0 rows affected (0.00 sec) mysql> CREATE TABLE Product     -> (     ->    ID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,     ->    ModelID SMALLINT UNSIGNED NOT NULL     -> ); Query OK, 0 rows affected (0.06 sec) mysql> CREATE INDEX index_1 ON Product (ModelID); Query OK, 0 rows affected (0.10 sec) Records: 0  Duplicates: 0  Warnings: 0 mysql> Describe Product; +---------+----------------------+------+-----+---------+-------+ | Field   | Type                 | Null | Key | Default | Extra | +---------+----------------------+------+-----+---------+-------+ | ID      | smallint(5) unsigned |      | PRI | 0       |       | | ModelID | smallint(5) unsigned |      | MUL | 0       |       | +---------+----------------------+------+-----+---------+-------+ 2 rows in set (0.01 sec) */ Drop table Product; CREATE TABLE Product (    ID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,    ModelID SMALLINT UNSIGNED NOT NULL ); CREATE INDEX index_1 ON Product (ModelID); Describe Product;