English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

SQLite Klauselindizes

“ INDEXED BY index-name

If index-The preparation of the SQLite statement fails if the name does not exist or cannot be used for the query.

The 'NOT INDEXED' clause specifies that an index is not used when accessing the table above, including implicit indexes created by UNIQUE and PRIMARY KEY constraints.

However, even if 'NOT INDEXED' is specified, entries can still be found using INTEGER PRIMARY KEY.

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);

Online Examples

In the table COMPANY, we will create an index and use it for the INDEXED BY operation.

sqlite> CREATE INDEX salary_index ON COMPANY(salary);
sqlite>

Currently selecting data from the table COMPANY, you can use the INDEXED BY clause as follows:

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

Dies wird das folgende Ergebnis erzeugen.

ID                            NAME                              AGE                                    ADDRESS                               SALARY
----------  ----------  ----------  ----------  ----------
7           James       24          Houston     10000.0
2           Allen       25          Texas       15000.0
1           Paul        32          California  20000.0
3           Teddy       23          Norway      20000.0
6           Kim         22          South-Hall  45000.0
4           Mark        25          Rich-Mond   65000.0
5           David       27          Texas       85000.0