SQLite - Index (indices)

Sqlite Banner

About

Relation - Index (Indices) in SQLite - SQLite command line

Internally, SQLite assumes that indices stored in database files are sorted according to the collation sequence indicated by the SQL schema. Changing the definition of a collation sequence after an index has been built is therefore equivalent to database corruption.

Management

Create

  • Unique 1)
CREATE UNIQUE INDEX IndexName ON TableName (colName1, ...);

Indexes can use:

  • order (ie ASC/DESC)
  • and COLLATE

Drop

2)

'drop' 'index' ['if' 'exists'] [ 'schema-name' '.'] 'index-name'

Alter

There is no alter index statement support. You need to drop and create again.

List

via pragma_index_info

SELECT DISTINCT m.name || '.' || ii.name AS 'indexed-columns'
  FROM sqlite_master AS m,
       pragma_index_list(m.name) AS il,
       pragma_index_info(il.name) AS ii
 WHERE m.type='table'
 ORDER BY 1;

Reference





Discover More
Sqlite Banner
How to create or add a Primary Key to a Sqlite Table

This article shows you how to add, create or modify a SQL primary key constraint The following schemas are logically equivalent because the primary keys are implemented by creating a unique index...
Sqlite Banner
SQLite - Unique Key (Indice)

in SQlite B is Unique (and has no name) With a index name
Sqlite Banner
Sqlite - Sql Grammar

The whole SQL syntax documentation for SQLite can be found at lang and/or full sql This error may be caused...



Share this page:
Follow us:
Task Runner