Change: ‘createIndex’

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

Available Attributes

NameDescriptionRequired ForSupportsSince
catalogNameName of the catalogall3.0
indexNameName of the index to createall
schemaNameName of the schemaall
tableNameName of the table to add the index toallall
tablespaceTablepace to create the index in.all
uniqueUnique values indexall1.8

Nested Properties

NameDescriptionRequired ForSupportsMultiple AllowedSince
columnsColumn(s) to add to the index

See the column tag documentation for more information
allallyes
<changeSet author="liquibase-docs" id="createIndex-example">
    <createIndex catalogName="cat"
            indexName="idx_address"
            schemaName="public"
            tableName="person"
            tablespace="A String"
            unique="true">
        <column name="address" type="varchar(255)"/>
    </createIndex>
</changeSet>
changeSet:
  id: createIndex-example
  author: liquibase-docs
  changes:
  - createIndex:
      catalogName: cat
      columns:
      - column:
          name: address
          type: varchar(255)
      indexName: idx_address
      schemaName: public
      tableName: person
      tablespace: A String
      unique: true
{
  "changeSet": {
    "id": "createIndex-example",
    "author": "liquibase-docs",
    "changes": [
      {
        "createIndex": {
          "catalogName": "cat",
          "columns": [
            {
              "column": {
                "name": "address",
                "type": "varchar(255)"
              }
            }]
          ,
          "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);

Database Support

DatabaseNotesAuto Rollback
DB2SupportedYes
DerbySupportedYes
FirebirdSupportedYes
H2SupportedYes
HyperSQLSupportedYes
InformixSupportedYes
MySQLSupportedYes
OracleSupportedYes
PostgreSQLSupportedYes
SQL ServerSupportedYes
SQLiteSupportedYes
SybaseSupportedYes
Sybase AnywhereSupportedYes

Missing, incomplete or wrong information? Please send a pull request