update-sql
The update-sql
command is a helper command that allows you to inspect the SQL Liquibase will run while using the update command.
Uses
The update-sql
command is used when you want to inspect the raw SQL before running the update command, so you can correct any issues that may arise before running the command. Liquibase uses the raw SQL to apply database changes you have added to the changelog file.
Running the update-sql
command
To run the update-sql
command, specify the driver, classpath, and URL in the Liquibase properties file. For more information, see Specifying Properties in a Connection Profile. You can also specify properties from the command line.
Run the update-sql
command:
liquibase --changelog-file=sample.changelog.xml update-sql
Note: Enter the name of the changelog you want to use in place of sample.changelog.xml
.
update-sql
global attributes
Attribute | Definition | Requirement |
---|---|---|
--changelog-file * |
Specifies the root changelog | Required |
--url
|
Specifies the JDBC database connection URL | Required |
--username
|
Specifies the database username | Required |
--password
|
Specifies the database password | Required |
--output-file ** |
Specifies the file path to where the update SQL will be written | Optional |
* Liquibase checks the changelog and any nested changelogs for the definitions of the changesets to update.
* * If not specified, update
SQL output goes to STDOUT
.
Note: The username
and password
attributes are not required for connections and systems which use alternate means of authentication.
update-sql
command attributes
Attribute | Definition | Requirement |
---|---|---|
--labels
|
Tags you can add to changesets to determine which changesets in the changelog to evaluate based on their labels | Optional |
--contexts
|
Expressions you can add to changesets to determine which changesets in the changelog to evaluate based on their contexts | Optional |

Liquibase Version: 4.9.1
Liquibase Community 4.9.1 by Liquibase
-- *********************************************************************
-- Update Database Script
-- *********************************************************************
-- Change Log: example-changelog.sql
-- Ran at: 5/9/22, 9:44 AM
-- Against: DBUSER@jdbc:h2:tcp://localhost:9090/mem:dev
-- Liquibase version: 4.9.1
-- *********************************************************************
-- Lock Database
UPDATE PUBLIC.DATABASECHANGELOGLOCK SET LOCKED = TRUE, LOCKEDBY = 'DESKTOP-SQVSSV2 (192.168.1.179)', LOCKGRANTED = NOW() WHERE ID = 1 AND LOCKED = FALSE;
-- Release Database Lock
UPDATE PUBLIC.DATABASECHANGELOGLOCK SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;
Liquibase command 'update-sql' was executed successfully.