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

NameDescription
cacheSizeintegerNumber of values to fetch per queryE.g. '371717'
catalogNameName of the catalog@ v3.0E.g. 'cat'
cyclebooleanCan the sequence cycle when it hits the max value?
dataTypeData type of the sequenceSupported by: asany, db2z, derby, firebird, h2, informix, postgresqlE.g. 'int'
incrementByintegerInterval between sequence numbersSupported by: asany, db2, db2z, derby, h2, hsqldb, informix, mssql, oracle, postgresqlE.g. '2'
maxValueintegerThe maximum value of the sequenceSupported by: asany, db2, db2z, derby, h2, informix, mssql, oracle, postgresqlE.g. '1000'
minValueintegerThe minimum value of the sequenceSupported by: asany, db2, db2z, derby, h2, informix, mssql, oracle, postgresqlE.g. '10'
orderedbooleanDoes the sequence need to be guaranteed to be generated in the order of request?Supported by: asany, db2, db2z, derby, firebird, h2, informix, mssql, oracle
schemaNameName of the schemaE.g. 'public'
sequenceNameName of the sequence to createE.g. 'seq_id'
startValueintegerThe first sequence number to be generated.Supported by: asany, db2, db2z, derby, h2, hsqldb, informix, mssql, oracle, postgresqlE.g. '5'
<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
DB2/LUWSupportedYes
DB2/zSupportedYes
DerbySupportedYes
FirebirdSupportedYes
H2SupportedYes
HyperSQLSupportedYes
INGRESNot SupportedYes
InformixSupportedYes
MariaDBNot SupportedYes
MySQLNot SupportedYes
OracleSupportedYes
PostgreSQLSupportedYes
SQL ServerSupportedYes
SQLiteNot SupportedYes
SybaseNot SupportedYes
Sybase AnywhereSupportedYes