sqlite

Database; use; embedded relational database

indexed

英['?ndekst] 美[ '?ndekst]

adj.Indexed, indexed, linked to the living index (or price index)

by

British [ba?] American [ba?]

prep.beside...;expression method;due to;passing through

adv.passing;used when expressing reservation or preservation;short visit

SQLite Indexed By function syntax

Function:The "INDEXED BY index-name" clause specifies that a named index must be needed to find the value in the previous table. If the index name index-name does not exist or cannot be used in the query, then preparation of the SQLite statement fails. The "NOT INDEXED" clause specifies that no index is used when accessing the preceding table (including implicit indexes created by UNIQUE and PRIMARY KEY constraints). However, even if "NOT INDEXED" is specified, the INTEGER PRIMARY KEY can still be used to find entries.

Syntax: The following is the syntax of the INDEXED BY clause, which can be used with DELETE, UPDATE or SELECT statements:

SELECT|DELETE|UPDATE column1, column2. ..
INDEXED BY (index_name)
table_name
WHERE (CONDITION);

SQLite Indexed By function example

表 COMPANY,我們將創(chuàng)建一個索引,并用它進行 INDEXED BY 操作。

sqlite> CREATE INDEX salary_index ON COMPANY(salary);
sqlite>
現(xiàn)在使用 INDEXED BY 子句從表 COMPANY 中選擇數(shù)據(jù),如下所示:

sqlite> SELECT * FROM COMPANY INDEXED BY salary_index WHERE salary > 5000;