Change: ‘addAutoIncrement’

Converts an existing column to be an auto-increment (a.k.a ‘identity’) column

Available Attributes

NameDescriptionRequired ForSupportsSince
catalogNameName of the catalogall3.0
columnDataTypeCurrent data type of the column to make auto-incrementinformix, sybase, unsupported, asany, hsqldb, h2, mysqlall
columnNameName of the columnallall
incrementByall
schemaNameName of the schemaall
startWithall
tableNameName of the tableallall
<changeSet author="liquibase-docs" id="addAutoIncrement-example">
    <addAutoIncrement catalogName="cat"
            columnDataType="int"
            columnName="id"
            incrementBy="1"
            schemaName="public"
            startWith="100"
            tableName="person"/>
</changeSet>
changeSet:
  id: addAutoIncrement-example
  author: liquibase-docs
  changes:
  - addAutoIncrement:
      catalogName: cat
      columnDataType: int
      columnName: id
      incrementBy: 1
      schemaName: public
      startWith: 100
      tableName: person
{
  "changeSet": {
    "id": "addAutoIncrement-example",
    "author": "liquibase-docs",
    "changes": [
      {
        "addAutoIncrement": {
          "catalogName": "cat",
          "columnDataType": "int",
          "columnName": "id",
          "incrementBy": 1,
          "schemaName": "public",
          "startWith": 100,
          "tableName": "person"
        }
      }]
    
  }
}

SQL Generated From Above Sample (MySQL)

ALTER TABLE cat.person MODIFY id INT AUTO_INCREMENT;

ALTER TABLE cat.person AUTO_INCREMENT=100;

Database Support

DatabaseNotesAuto Rollback
DB2SupportedNo
DerbyNot SupportedNo
FirebirdNot SupportedNo
H2SupportedNo
HyperSQLSupportedNo
InformixSupportedNo
MySQLSupportedNo
OracleNot SupportedNo
PostgreSQLSupportedNo
SQL ServerNot SupportedNo
SQLiteSupported: If the column type is not INTEGER it is converted to INTEGERNo
SybaseSupportedNo
Sybase AnywhereSupportedNo

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