Adds a unique constrant to an existing column or set of columns.
Name | Description |
---|---|
catalogName | Name of the catalog@ v3.0E.g. 'cat' |
clustered | booleanWhether create a clustered indexSupported by: mssql |
columnNames | Name of the column(s) to create the unique constraint on. Comma separated if multipleE.g. 'id, name' |
constraintName | Name of the unique constraintE.g. 'const_name' |
deferrable | booleanTrue if this constraint is deferrable, False otherwise |
disabled | booleanTrue if this constraint is disabled, False otherwise |
forIndexCatalogName | |
forIndexName | E.g. 'A String'Supported by: oracle |
forIndexSchemaName | |
initiallyDeferred | booleanTrue if this constraint is initially deferred, False otherwise |
schemaName | Name of the schemaE.g. 'public' |
tableName | Name of the table to create the unique constraint onE.g. 'person' |
tablespace | 'Tablespace' to create the index in. Corresponds to file group in mssqlE.g. 'A String' |
validate | booleanShould be true if the unique constraint shall 'ENABLE VALIDATE' set, or false if the 'ENABLE NOVALIDATE' shall.Default: true |
<changeSet author="liquibase-docs" id="addUniqueConstraint-example">
<addUniqueConstraint catalogName="cat"
clustered="true"
columnNames="id, name"
constraintName="const_name"
deferrable="true"
disabled="true"
forIndexName="A String"
initiallyDeferred="true"
schemaName="public"
tableName="person"
tablespace="A String"
validate="true"/>
</changeSet>
changeSet:
id: addUniqueConstraint-example
author: liquibase-docs
changes:
- addUniqueConstraint:
catalogName: cat
clustered: true
columnNames: id, name
constraintName: const_name
deferrable: true
disabled: true
forIndexName: A String
initiallyDeferred: true
schemaName: public
tableName: person
tablespace: A String
validate: true
{
"changeSet": {
"id": "addUniqueConstraint-example",
"author": "liquibase-docs",
"changes": [
{
"addUniqueConstraint": {
"catalogName": "cat",
"clustered": true,
"columnNames": "id, name",
"constraintName": "const_name",
"deferrable": true,
"disabled": true,
"forIndexName": "A String",
"initiallyDeferred": true,
"schemaName": "public",
"tableName": "person",
"tablespace": "A String",
"validate": true
}
}]
}
}
ALTER TABLE cat.person ADD CONSTRAINT const_name UNIQUE CLUSTERED (id,
name) USING INDEX `A String`;
Database | Notes | Auto Rollback |
---|---|---|
DB2/LUW | Supported | Yes |
DB2/z | Supported | Yes |
Derby | Supported | Yes |
Firebird | Supported | Yes |
H2 | Supported | Yes |
HyperSQL | Supported | Yes |
INGRES | Supported | Yes |
Informix | Supported | Yes |
MariaDB | Supported | Yes |
MySQL | Supported | Yes |
Oracle | Supported | Yes |
PostgreSQL | Supported | Yes |
SQL Server | Supported | Yes |
SQLite | Not Supported | Yes |
Sybase | Supported | Yes |
Sybase Anywhere | Supported | Yes |