executeCommand

The executeCommand Change Type executes a system command.

Note: Using Liquibase commands such as migrateSQL may not work as expected because the executeCommand Change Type doesn't generate SQL. To resolve this, use Change Types that generate SQL.

Uses

You can typically use the executeCommand Change Type to run a script using a specific executable. One reason to use executeCommand is to insert or update data.

Running the executeCommand Change Type

To run this Change Type, follow these steps:

  1. Add the Change Type to your changeset, as shown in the examples on this page.
  2. Specify any required attributes. Use the table on this page to see which ones your database requires.
  3. Deploy your changeset by running the update command:
  4. liquibase update

Available attributes

Name Description Required for Supports
executable The name of the executable to run all all
os The list of operating systems on which to execute the command (taken from the os.name Java system property) all
timeout The timeout value for executable to run all

Nested tags

Name Description Required for Supports Multiple allowed
args / arg Arguments for the executable all yes

Nested property attributes

Name Description Required for Supports Multiple allowed
value The value of the attribute (for example: '-param')    

Examples

databaseChangeLog:
-  changeSet:
    id:  executeCommand-example
    author:  liquibase-docs
    changes:
    -  executeCommand:
        args:
        -  arg:
            value:  -out
        -  arg:
            value:  -param2
        executable:  mysqldump
        os:  Windows 7
        timeout:  10s
{
    "databaseChangeLog": [
        {
            "changeSet": {
                "id": "executeCommand-example",
                "author": "liquibase-docs",
                "changes": [
                    {
                        "executeCommand": {
                            "args": [
                                {
                                    "arg": {
                                        "value": "-out"
                                    },
                                    "arg": {
                                        "value": "-param2"
                                    }
                                }
                            ],
                            "executable": "mysqldump",
                            "os": "Windows 7",
                            "timeout": "10s"
                        }
                    }
                ]
            }
        }
    ]
}
<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="executeCommand-example">
        <executeCommand  executable="mysqldump"
            os="Windows 7"
            timeout="10s">
            <arg  value="-out"/>
            <arg  value="-param2"/>
        </executeCommand>
    </changeSet>

</databaseChangeLog>

Database support

Database Notes Auto Rollback
DB2/LUW Supported No
DB2/z Supported No
Derby Supported No
Firebird Supported No
Google BigQuery 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