Liquibase® version 3.8.1 is now available! Get it for free.
2018 XML Announcement
News Liquibase 3.8.1 Released
06 Nov 2019

- and/or -

All Previous Posts >>

Change: ‘dropForeignKeyConstraint’

Drops an existing foreign key

Available Attributes

NameDescriptionRequired ForSupportsSince
baseTableCatalogNameall3.0
baseTableNameName of the table containing the column constrained by the foreign keyallall
baseTableSchemaNameall
constraintNameName of the foreign key constraint to dropallall
<changeSet author="liquibase-docs"
        id="dropForeignKeyConstraint-example"
        objectQuotingStrategy="LEGACY">
    <dropForeignKeyConstraint baseTableCatalogName="cat"
            baseTableName="person"
            baseTableSchemaName="public"
            constraintName="fk_address_person"/>
</changeSet>
changeSet:
  id: dropForeignKeyConstraint-example
  author: liquibase-docs
  objectQuotingStrategy: LEGACY
  changes:
  - dropForeignKeyConstraint:
      baseTableCatalogName: cat
      baseTableName: person
      baseTableSchemaName: public
      constraintName: fk_address_person
{
  "changeSet": {
    "id": "dropForeignKeyConstraint-example",
    "author": "liquibase-docs",
    "objectQuotingStrategy": "LEGACY",
    "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
DB2SupportedNo
DB2SupportedNo
DerbySupportedNo
FirebirdSupportedNo
H2SupportedNo
HyperSQLSupportedNo
INGRESSupportedNo
InformixSupportedNo
MariaDBSupportedNo
MySQLSupportedNo
OracleSupportedNo
PostgreSQLSupportedNo
SQL ServerSupportedNo
SQLiteNot SupportedNo
SybaseSupportedNo
Sybase AnywhereSupportedNo