Need Liquibase® support? Liquibase Pro is now available! Try it out free.
2018 XML Announcement

Change: ‘addCheckConstraint’

Adds a check constrant to an existing column or set of columns.

Available Attributes

NameDescriptionRequired ForSupportsSince
catalogNameName of the catalogall3.0
constraintBodyallall
constraintNameName of the check constraintallall
disabledall
schemaNameName of the schemaall
tableNameName of the table to create the check constraint onallall
validateThis is true if the check constraint has 'ENABLE VALIDATE' set, or false if the check constraint has 'ENABLE NOVALIDATE' set.all
<changeSet author="liquibase-docs"
        id="addCheckConstraint-example"
        objectQuotingStrategy="LEGACY">
    <ext:addCheckConstraint catalogName="cat"
            constraintName="const_name"
            disabled="true"
            schemaName="public"
            tableName="person"
            validate="true">A String</ext:addCheckConstraint>
</changeSet>
changeSet:
  id: addCheckConstraint-example
  author: liquibase-docs
  objectQuotingStrategy: LEGACY
  changes:
  - addCheckConstraint:
      catalogName: cat
      constraintBody: A String
      constraintName: const_name
      disabled: true
      schemaName: public
      tableName: person
      validate: true
{
  "changeSet": {
    "id": "addCheckConstraint-example",
    "author": "liquibase-docs",
    "objectQuotingStrategy": "LEGACY",
    "changes": [
      {
        "addCheckConstraint": {
          "catalogName": "cat",
          "constraintBody": "A String",
          "constraintName": "const_name",
          "disabled": true,
          "schemaName": "public",
          "tableName": "person",
          "validate": true
        }
      }]
    
  }
}

SQL Generated From Above Sample (SQL Server)

ALTER TABLE cat.[public].person ADD CONSTRAINT const_name CHECK (A String);

ALTER TABLE cat.[public].person NOCHECK CONSTRAINT const_name;

Database Support

DatabaseNotesAuto Rollback
DB2SupportedNo
DerbyNot SupportedNo
FirebirdNot SupportedNo
H2Not SupportedNo
HyperSQLNot SupportedNo
INGRESNot SupportedNo
InformixNot SupportedNo
MariaDBNot SupportedNo
MySQLNot SupportedNo
OracleSupportedNo
PostgreSQLSupportedNo
SQL ServerSupportedNo
SQLiteNot SupportedNo
SybaseNot SupportedNo
Sybase AnywhereNot SupportedNo