PostgreSQL · Command
CREATE INDEX
CREATE INDEX builds an index on a table or materialized view. It can index columns or expressions and can support faster searches, sorting, partial indexes, and index-only scans.
Last updated
Syntax
CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] name ] ON [ ONLY ] table_name [ USING method ] ( { column_name | ( expression ) } [ COLLATE collation ] [ opclass [ ( opclass_parameter = value [, ... ] ) ] ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ) [ INCLUDE ( column_name [, ...] ) ] [ NULLS [ NOT ] DISTINCT ] [ WITH ( storage_parameter [= value ] [, ...] ) ] [ TABLESPACE tablespace_name ] [ WHERE predicate ]In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
CREATE TABLEALTER INDEXANALYZEmaintenance_work_memindex-only scanpartial indexB-treeGiST