Tip: The command uses syntax for Liquibase 4.4 and later. For earlier versions, use a camel case syntax and the following CLI order: [command parameters] [command] [global parameters]. To find the previous format of the command, run the liquibase --help command and refer to the deprecated version.

The execute-sql command executes a SQL string or file.


Use the execute-sql command to directly run SQL queries without changing and applying changelog files with changesets. An example of using the execute-sql command is to check the database data or make unplanned changes when you run Liquibase in automation.

Compared with other database query tools, the execute-sql command runs with the credentials and configuration you already have in Liquibase without any need to set up another tool. If statements run correctly in your database CLI but fail in Liquibase, running exploratory statements through execute-sql might help you find differences in permission configurations, connection setup, and SQL run in the database CLI or database-native SQL.

Note: The command does not affect the DATABASECHANGELOG table because the table is associated with changesets and tracks which changesets have been run. Liquibase recommends handling your changes with execute-sql only on rare occasions to not lose their traceability.

Running the execute-sql command

To run the execute-sql command, specify the following parameters in the Liquibase properties file, environment variables, or the command prompt while running the command:

Note: For more information about the options to store parameters, see Specifying Properties in a Connection Profile, Liquibase Environment Variables, and JAVA_OPTS Environment Variable. To find the format of a parameter, see Command Parameters.

Run the execute-sql command with the SQL string:

liquibase execute-sql --sql="select * from databasechangelog"

Run the execute-sql command with the SQL file:

liquibase execute-sql --sql-file=path/to/file.sql

Note: You can also specify --delimiter=/. The default value for delimiter is ;, which will work as long as you do not have stored logic.

execute-sql command parameters

Tip: For best results, specify all commands and parameters with the --kebab-case format in the CLI. If your preference is camelCase, it will still work in the CLI.

Parameter Definition Requirement

The JDBC database connection URL


The SQL string to execute


The SQL file with a script to execute


The database username


The database password


The default catalog name to use for the database connection


The default schema name to use for the database connection


The delimiter to use when executing SQL scripts


The JDBC driver class


The JDBC driver properties file


Note: The username and password attributes are not required for connections and systems which use alternate means of authentication.