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

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

Available Attributes

NameDescription
catalogNameName of the catalog@ v3.0E.g. 'cat'
[XML: text content] / constraintBodyE.g. 'A String'Note: the content of the tag in XML
constraintNameName of the check constraintE.g. 'const_name'
disabledboolean
schemaNameName of the schemaE.g. 'public'
tableNameName of the table to create the check constraint onE.g. 'person'
validatebooleanThis is true if the check constraint has 'ENABLE VALIDATE' set, or false if the check constraint has 'ENABLE NOVALIDATE' set.
<changeSet author="liquibase-docs" id="addCheckConstraint-example">
    <pro:addCheckConstraint catalogName="cat"
            constraintName="const_name"
            disabled="true"
            schemaName="public"
            tableName="person"
            validate="true">A String</pro:addCheckConstraint>
</changeSet>
changeSet:
  id: addCheckConstraint-example
  author: liquibase-docs
  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",
    "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
DB2/LUWSupportedYes
DB2/zSupportedYes
DerbyNot SupportedYes
FirebirdNot SupportedYes
H2Not SupportedYes
HyperSQLNot SupportedYes
INGRESNot SupportedYes
InformixNot SupportedYes
MariaDBNot SupportedYes
MySQLNot SupportedYes
OracleSupportedYes
PostgreSQLSupportedYes
SQL ServerSupportedYes
SQLiteNot SupportedYes
SybaseNot SupportedYes
Sybase AnywhereNot SupportedYes