SQL Alter Table Indexes.

Creating Indexes with the ALTER TABLE statement.

In some RDBMS you can create indexes with the ALTER TABLE statement.
Syntax:
MySQL:
ALTER TABLE table_name
  ADD [UNIQUE] INDEX constraint_name (column_name, ....),
  ADD [UNIQUE] INDEX constraint_name (column_name, ....), .....;
Add Index example:
ALTER TABLE BOOKSTORE
  ADD INDEX SHORT_IND (SHORT_DESC),
  ADD INDEX ISNB_AUTHOR_IND (ISBN_NO, AUTHOR);
The index, ISNB_AUTHOR_IND, is defined as a composite index for ISBN_NO and AUTHOR columns, while SHORT_IND is an index for a single column, SHORT_DESC.
Add Unique Index example:
ALTER TABLE BOOKSTORE
  ADD UNIQUE INDEX SHORTDESC_IND (SHORT_DESC, PUBLISHER),
  ADD UNIQUE INDEX AUTHOR_IND (AUTHOR);
The index, SHORT_DESC_IND, is defined as a composite unique index for SHORT_DESC and PUBLISHER columns, while the AUTHOR_IND is a UNIQUE INDEX for a single column, AUTHOR.
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.