Liquibase® version 3.8.1 is now available! Get it for free.
2018 XML Announcement
News Liquibase 3.8.1 Released
06 Nov 2019

- and/or -

All Previous Posts >>

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 sequenceall
incrementByInterval between sequence numbersinformix, oracle, postgresql, hsqldb, db2, asany, db2z, derby, h2, mssql
maxValueThe maximum value of the sequenceinformix, oracle, postgresql, db2, asany, db2z, derby, h2, mssql
minValueThe minimum value of the sequenceinformix, oracle, postgresql, db2, asany, db2z, derby, h2, mssql
orderedDoes the sequence need to be guaranteed to be genererated inm the order of request?informix, firebird, oracle, db2, asany, db2z, derby, h2, mssql
schemaNameName of the schemaall
sequenceNameName of the sequence to createallall
startValueThe first sequence number to be generated.informix, oracle, postgresql, hsqldb, db2, asany, db2z, derby, h2, mssql
<changeSet author="liquibase-docs"
        id="createSequence-example"
        objectQuotingStrategy="LEGACY">
    <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
  objectQuotingStrategy: LEGACY
  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",
    "objectQuotingStrategy": "LEGACY",
    "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 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 ServerSupported (after 2012)Yes
SQLiteNot SupportedYes
SybaseNot SupportedYes
Sybase AnywhereSupportedYes