CREATE INDEX
Attention
This page documents an earlier version. Go to the latest (v2.3) version.Synopsis
Syntax
create_index ::= CREATE [ UNIQUE ] INDEX [ [ IF NOT EXISTS ] name ]
ON [ ONLY ] table_name ( index_elem [ , ... ] )
[ INCLUDE ( column_name [ , ... ] ) ]
[ WHERE predicate ]
index_elem ::= { column_name | ( expression ) } [ opclass ]
[ ASC | DESC ]
create_index
index_elem
Semantics
CONCURRENTLY
, USING method
, COLLATE
, NULL
order, and TABLESPACE
options are not yet supported.
create_index
UNIQUE
Enforce that duplicate values in a table are not allowed.
INCLUDE clause
Specify a list of columns which will be included in the index as non-key columns.
name
Specify the name of the index to be created.
table_name
Specify the name of the table to be indexed.
index_elem
column_name
Specify the name of a column of the table.
expression
Specify one or more columns of the table and must be surrounded by parentheses.
ASC
— Sort in ascending order.DESC
— Sort in descending order.