SQLite Indexed By
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 for the query, then the 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, INTEGER PRIMARY KEY can still be used to find entries.
Syntax
The following is the syntax for the INDEXED BY clause, which can be used with a DELETE, UPDATE, or SELECT statement:
INDEXED BY (index_name)
table_name
WHERE (CONDITION);
Instance
Assuming there is table COMPANY, we will Create an index and use it for INDEXED BY operations.
sqlite>
Now use INDEXED BY clause to select data from table COMPANY as shown below :
sqlite> SELECT * FROM COMPANY INDEXED BY salary_index WHERE salary > 5000;