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: ‘createSequence’

Creates a new database sequence

Available Attributes

NameDescriptionRequired ForSupportsSince
cacheSizeNumber of values to fetch per queryall
catalogNameName of the catalogall3.0
cycleCan the sequence cycle when it hits the max value?all
dataTypeData type of the sequenceasany, db2z, derby, firebird, h2, informix, postgresql
incrementByInterval between sequence numbersasany, db2, db2z, derby, h2, hsqldb, informix, mssql, oracle, postgresql
maxValueThe maximum value of the sequenceasany, db2, db2z, derby, h2, informix, mssql, oracle, postgresql
minValueThe minimum value of the sequenceasany, db2, db2z, derby, h2, informix, mssql, oracle, postgresql
orderedDoes the sequence need to be guaranteed to be genererated inm the order of request?asany, db2, db2z, derby, firebird, h2, informix, mssql, oracle
schemaNameName of the schemaall
sequenceNameName of the sequence to createallall
startValueThe first sequence number to be generated.asany, db2, db2z, derby, h2, hsqldb, informix, mssql, oracle, postgresql
<changeSet author="liquibase-docs" id="createSequence-example">
    <createSequence cacheSize="371717"
            catalogName="cat"
            cycle="true"
            dataType="int"
            incrementBy="2"
            maxValue="1000"
            minValue="10"
            ordered="true"
            schemaName="public"
            sequenceName="seq_id"
            startValue="5"/>
</changeSet>
changeSet:
  id: createSequence-example
  author: liquibase-docs
  changes:
  - createSequence:
      cacheSize: 371717
      catalogName: cat
      cycle: true
      dataType: int
      incrementBy: 2
      maxValue: 1000
      minValue: 10
      ordered: true
      schemaName: public
      sequenceName: seq_id
      startValue: 5
{
  "changeSet": {
    "id": "createSequence-example",
    "author": "liquibase-docs",
    "changes": [
      {
        "createSequence": {
          "cacheSize": 371717,
          "catalogName": "cat",
          "cycle": true,
          "dataType": "int",
          "incrementBy": 2,
          "maxValue": 1000,
          "minValue": 10,
          "ordered": true,
          "schemaName": "public",
          "sequenceName": "seq_id",
          "startValue": 5
        }
      }]
    
  }
}

SQL Generated From Above Sample (SQL Server)

CREATE SEQUENCE [public].seq_id AS int START WITH 5 INCREMENT BY 2 MINVALUE 10 MAXVALUE 1000 ORDER CYCLE;

Database Support

DatabaseNotesAuto Rollback
DB2SupportedYes
DB2SupportedYes
DerbySupportedYes
FirebirdSupportedYes
H2SupportedYes
HyperSQLSupportedYes
INGRESNot SupportedYes
InformixSupportedYes
MariaDBNot SupportedYes
MySQLNot SupportedYes
OracleSupportedYes
PostgreSQLSupportedYes
SQL ServerSupportedYes
SQLiteNot SupportedYes
SybaseNot SupportedYes
Sybase AnywhereSupportedYes