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

Drops an existing foreign key

Available Attributes

NameDescription
baseTableCatalogName@ v3.0E.g. 'cat'
baseTableNameName of the table containing the column constrained by the foreign keyE.g. 'person'
baseTableSchemaNameE.g. 'public'
constraintNameName of the foreign key constraint to dropE.g. 'fk_address_person'
<changeSet author="liquibase-docs" id="dropForeignKeyConstraint-example">
    <dropForeignKeyConstraint baseTableCatalogName="cat"
            baseTableName="person"
            baseTableSchemaName="public"
            constraintName="fk_address_person"/>
</changeSet>
changeSet:
  id: dropForeignKeyConstraint-example
  author: liquibase-docs
  changes:
  - dropForeignKeyConstraint:
      baseTableCatalogName: cat
      baseTableName: person
      baseTableSchemaName: public
      constraintName: fk_address_person
{
  "changeSet": {
    "id": "dropForeignKeyConstraint-example",
    "author": "liquibase-docs",
    "changes": [
      {
        "dropForeignKeyConstraint": {
          "baseTableCatalogName": "cat",
          "baseTableName": "person",
          "baseTableSchemaName": "public",
          "constraintName": "fk_address_person"
        }
      }]
    
  }
}

SQL Generated From Above Sample (MySQL)

ALTER TABLE cat.person DROP FOREIGN KEY fk_address_person;

Database Support

DatabaseNotesAuto Rollback
DB2/LUWSupportedNo
DB2/zSupportedNo
DerbySupportedNo
FirebirdSupportedNo
H2SupportedNo
HyperSQLSupportedNo
INGRESSupportedNo
InformixSupportedNo
MariaDBSupportedNo
MySQLSupportedNo
OracleSupportedNo
PostgreSQLSupportedNo
SQL ServerSupportedNo
SQLiteNot SupportedNo
SybaseSupportedNo
Sybase AnywhereSupportedNo