Liquibase® version 3.8.5 is now available! Get it for free.
2018 XML Announcement
News All Previous Posts >>

Subscribe for email updates

- and/or -

Change: ‘createIndex’

Creates an index on an existing column or set of columns.

Available Attributes

NameDescription
catalogNameName of the catalog@ v3.0E.g. 'cat'
clusteredbooleanCreate clustered index.
indexNameName of the index to createE.g. 'idx_address'Required for: firebird, hsqldb
schemaNameName of the schemaE.g. 'public'
tableNameName of the table to add the index toE.g. 'person'
tablespaceTablespace to create the index in.E.g. 'A String'
uniquebooleanUnique values index@ v1.8

Nested Properties

NameDescription
columns / column [1..N]Column(s) to add to the indexNote: columns tag not required in XML
Attributes
name Name of the column needs to be included in the index. It can contain the sort direction by appending " ASC" or " DESC" to the name.
computed boolean Set it true if the value in "name" isn't actually a column name but a function. @ v3.3
descending boolean Allows to specify that the column should be used in descending order in the index.(i.e. ascending order) @ v3.4
<changeSet author="liquibase-docs" id="createIndex-example">
    <createIndex catalogName="cat"
            clustered="true"
            indexName="idx_address"
            schemaName="public"
            tableName="person"
            tablespace="A String"
            unique="true">
        <column descending="true" name="address"/>
    </createIndex>
</changeSet>
changeSet:
  id: createIndex-example
  author: liquibase-docs
  changes:
  - createIndex:
      catalogName: cat
      clustered: true
      columns:
      - column:
          descending: true
          name: address
      indexName: idx_address
      schemaName: public
      tableName: person
      tablespace: A String
      unique: true
{
  "changeSet": {
    "id": "createIndex-example",
    "author": "liquibase-docs",
    "changes": [
      {
        "createIndex": {
          "catalogName": "cat",
          "clustered": true,
          "columns": [
            {
              "column": {
                "descending": true,
                "name": "address"
              }
            }]
          ,
          "indexName": "idx_address",
          "schemaName": "public",
          "tableName": "person",
          "tablespace": "A String",
          "unique": true
        }
      }]
    
  }
}

SQL Generated From Above Sample (MySQL)

CREATE UNIQUE INDEX idx_address ON cat.person(address DESC);

Database Support

DatabaseNotesAuto Rollback
DB2/LUWSupportedYes
DB2/zSupportedYes
DerbySupportedYes
FirebirdSupportedYes
H2SupportedYes
HyperSQLSupportedYes
INGRESSupportedYes
InformixSupportedYes
MariaDBSupportedYes
MySQLSupportedYes
OracleSupportedYes
PostgreSQLSupportedYes
SQL ServerSupportedYes
SQLiteSupportedYes
SybaseSupportedYes
Sybase AnywhereSupportedYes