Examples of Secondary Index

tsinglee發表於2007-11-22

引用自http://developer.mimer.com/documentation/html_92/Mimer_SQL_Mobile_DocSet/Defining_Database9.html

Create a secondary index called ITM_RELEASE_DATE on the RELEASE_DATE column in the ITEMS table:
CREATE INDEX itm_release_date ON items(release_date);

Primary key columns may also be included in a secondary index. If a table has the primary key
columns A, B, and C, the primary index would cover all three columns of the primary key.

The following combinations of the columns in the primary key are automatically indexed: A, AB, and
ABC. In addition, you could create secondary indexes on columns B, C, BC, AC etc.

An index may also be defined as UNIQUE, which means that the index value may only occur once in the
table. (For this purpose, NULL is treated as equal to NULL). However, it is preferable to use unique
constraints.

Create a UNIQUE secondary index called ITM_EAN_CODE on the EAN_CODE column in the ITEMS table:
CREATE UNIQUE INDEX itm_ean_code ON ITEMS(ean_code);

Sorting Indexes
The sorting order for indexes may be defined as ascending or descending. However, this makes no
difference to the efficiency of the index, since Mimer SQL searches indexes forwards or backwards
depending on the circumstances.

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10599713/viewspace-983310/,如需轉載,請註明出處,否則將追究法律責任。

相關文章