Wednesday 18 January 2012

Creating Indexes in MySQL

This example shows how to create single and multi-column indexes in MySQL. There appears to be nothing to stop you creating two indexes with the same name, as long as they are on separate tables. Then it shows how to list the indexes on a table. As always, click on the image to display it at its actual size and bring it into focus:


You can drop indexes as follows. Note that you have to include the table name in case there is more than one index with a given name:
 
--------------
drop index i on t1
--------------
 
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
--------------
drop index i on t2
--------------
 
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

No comments: