addCheckConstraint
Adds a check constraint to an existing column or set of columns.
Available attributes
Name |
Description |
Required for |
Supports |
Since |
catalogName |
Name of the catalog |
|
all |
3.0 |
constraintBody |
|
all |
all |
|
constraintName |
Name of the check constraint |
all |
all |
|
disabled |
|
|
all |
|
schemaName |
Name of the schema |
|
all |
|
tableName |
Name of the table to create the check constraint on |
all |
all |
|
validate |
This is true if the check constraint has 'ENABLE VALIDATE' set, or false if the check constraint has 'ENABLE NOVALIDATE' set. |
|
all |
|
XML example
<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>
YAML example
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
JSON example
{ "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 example
ALTER TABLE cat.[public].person ADD CONSTRAINT const_name CHECK (A String);
ALTER TABLE cat.[public].person NOCHECK CONSTRAINT const_name;
Database support
DB2/LUW |
Supported
|
Yes
|
DB2/z |
Supported
|
Yes
|
Derby |
Not Supported |
Yes
|
Firebird |
Not Supported |
Yes
|
H2 |
Not Supported |
Yes
|
HyperSQL |
Not Supported |
Yes
|
INGRES |
Not Supported |
Yes
|
Informix |
Not Supported |
Yes
|
MariaDB |
Not Supported |
Yes
|
MySQL |
Not Supported |
Yes
|
Oracle |
Supported
|
Yes
|
PostgreSQL |
Supported
|
Yes
|
SQL Server |
Supported
|
Yes
|
SQLite |
Not Supported |
Yes
|
Sybase |
Not Supported |
Yes
|
Sybase Anywhere |
Not Supported |
Yes
|