Adding Indexes to Existing Tables

You don't have to add indexes at the same time that you create a table. You can add indexes to existing tables using the CREATE INDEX command. The exact syntax is very similar to the INDEX clause of a CREATE TABLE command:

CREATE INDEX index_name ON table_name(list, of, columns, ...) 

For example, in the book table, you might want to speed up ordering and matching operations on the title column. Adding an index to the title column is a good way to do this. To add the index, run the following query:

CREATE INDEX title ON book (title(16)); 

The index is explicitly limited to the first 16 characters of the title. This gives you an accurate index but is much more efficient for storage than placing an index of up to 255 characters.

MySQL Phrasebook. Essential Code and Commands
MySQL Phrasebook
ISBN: 0672328399
EAN: 2147483647
Year: 2003
Pages: 130

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: