dropColumn

The dropColumn Change Type drops existing columns.

To drop a single column, use the simple form of this element where the tableName and columnName are specified as attributes.

To drop several columns, specify the tableName as an attribute, and then specify a set of nested <column> tags. If nested <column> tags are present, the columnName attribute will be ignored. Alternatively, you can use separate dropColumn statements to drop more than one column.

Available attributes

Name Description Required for Supports Since
catalogName

Name of the catalog

all 3.0
columnName Name of the column to drop, if dropping a single column. Ignored if nested columns are defined all
schemaName

Name of the schema

all
tableName Name of the table containing the column to drop all all

Nested tags

Name Description Required for Supports Multiple allowed
column

Columns to be dropped if dropping multiple columns. If this is populated, the columnName attribute is ignored.

Note: YAML and JSON changelogs using the column tag must nest it within a columns tag.

all yes

Examples

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xmlns:pro="http://www.liquibase.org/xml/ns/pro"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
        http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">

    <changeSet author="liquibase-docs" id="dropColumn-example">
        <dropColumn catalogName="cat"
                       columnName="id"
                       schemaName="public"
                       tableName="person">
            <column name="address1"/>
        </dropColumn>
        <dropColumn catalogName="cat"
	                   columnName="id"
	                   schemaName="public"
	                   tableName="person">
	        <column name="address2"/>
        </dropColumn>
    </changeSet>

</databaseChangeLog>
databaseChangeLog:
-  changeSet:
    id:  dropColumn-example
    author:  liquibase-docs
    changes:
    -  dropColumn:
        catalogName:  cat
        columnName:  id
        columns:
        -  column:
            name:  address
        schemaName:  public
        tableName:  person
{
    "databaseChangeLog": [
        {
            "changeSet": {
                "id": "dropColumn-example",
                "author": "liquibase-docs",
                "changes": [
                    {
                        "dropColumn": {
                            "catalogName": "cat",
                            "columnName": "id",
                            "columns": [
                                {
                                    "column": {
                                        "name": "address"
                                    }
                                }
                            ],
                            "schemaName": "public",
                            "tableName": "person"
                        }
                    }
                ]
            }
        }
    ]
}
--liquibase formatted sql

--changeset liquibase-docs:dropColumn-example
ALTER  TABLE  cat.person  DROP  COLUMN  address;

Database support

Database Notes Auto Rollback
DB2/LUW Supported No
DB2/z Not Supported No
Derby Supported No
Firebird Supported No
H2 Supported No
HyperSQL Supported No
INGRES Supported No
Informix Supported No
MariaDB Supported No
MySQL Supported No
Oracle Supported No
PostgreSQL Supported No
Snowflake Supported No
SQL Server Supported No
SQLite Supported No
Sybase Supported No
Sybase Anywhere Supported No