Liquibase
works on ChangeLog
files that contain prewritten ChangeSets
of DDL
and DML
. Still, sometimes, it's required to make unplanned changes or just run a few queries to check if the database is up, permissions, or validate the access.
Liquibase
provides executeSql
command, that will connect to the database using the credentials mentioned in the liquibase.properties
file.
the execute-sql command will not affect the DATABASECHANGELOG table
The SQL
query can be passed in the command line as below
liquibase executeSql --sql="SELECT * FROM databasechangelog"
or from an SQL file
such as file.sql
SELECT * FROM databasechangelog
now executes the command
liquibase executeSql --sql-file=file.sql