Converts an existing column to be an auto-increment (a.k.a ‘identity’) column
Name | Description |
---|---|
catalogName | Name of the catalog@ v3.0E.g. 'cat' |
columnDataType | Current data type of the column to make auto-incrementRequired for: asany, h2, hsqldb, informix, ingres, mariadb, mysql, sybase, unsupportedE.g. 'int' |
columnName | Name of the columnE.g. 'id' |
defaultOnNull | booleanWhen using generationType 'BY DEFAULT' then defaultOnNull = true allows the identity to be used if the identity column is referenced, but a value of NULL is specified.@ v3.6Supported by: oracle |
generationType | Type of the generation in 'GENERATED %s AS IDENTITY'. ALWAYS | BY DEFAULT@ v3.6E.g. 'ALWAYS' |
incrementBy | integerThe value the increment incremented by each callE.g. '1' |
schemaName | Name of the schemaE.g. 'public' |
startWith | integerInitial value of the incrementE.g. '100' |
tableName | Name of the tableE.g. 'person' |
<changeSet author="liquibase-docs" id="addAutoIncrement-example">
<addAutoIncrement catalogName="cat"
columnDataType="int"
columnName="id"
defaultOnNull="false"
generationType="ALWAYS"
incrementBy="1"
schemaName="public"
startWith="100"
tableName="person"/>
</changeSet>
changeSet:
id: addAutoIncrement-example
author: liquibase-docs
changes:
- addAutoIncrement:
catalogName: cat
columnDataType: int
columnName: id
defaultOnNull: false
generationType: ALWAYS
incrementBy: 1
schemaName: public
startWith: 100
tableName: person
{
"changeSet": {
"id": "addAutoIncrement-example",
"author": "liquibase-docs",
"changes": [
{
"addAutoIncrement": {
"catalogName": "cat",
"columnDataType": "int",
"columnName": "id",
"defaultOnNull": false,
"generationType": "ALWAYS",
"incrementBy": 1,
"schemaName": "public",
"startWith": 100,
"tableName": "person"
}
}]
}
}
ALTER TABLE cat.person MODIFY id INT AUTO_INCREMENT;
ALTER TABLE cat.person AUTO_INCREMENT=100;
Database | Notes | Auto Rollback |
---|---|---|
DB2/LUW | Supported | No |
DB2/z | Supported | No |
Derby | Not Supported | No |
Firebird | Not Supported | No |
H2 | Supported | No |
HyperSQL | Supported | No |
INGRES | Supported | No |
Informix | Supported | No |
MariaDB | Supported | No |
MySQL | Supported | No |
Oracle | Not Supported | No |
PostgreSQL | Supported | No |
SQL Server | Not Supported | No |
SQLite | Supported: If the column type is not INTEGER it is converted to INTEGER | No |
Sybase | Supported | No |
Sybase Anywhere | Supported | No |