|
CREATE [UNIQUE] INDEX <index name> ON <table name>
(<column name> [ASC | DESC])
|
The general syntax to create index is as shown as above. Creating
index is fairly simple and straight forward. The unique keyword allows you to
specify whether the table allows duplicate field or not. If UNIQUE is set, no
two rows in the database can have exact index values. The optional ASC | DESC
defines whether the records in the table is sorted in ascending or descending
order. Usually, database vendor will default it to ASC. So far, I have
never seen any database vendor that default it to DESC.
Index is very important in your database performance. It allows the
DBMS to find data more quickly and joint table more efficiently. However,
overuse of index will cause the data insertion slower.