objectQuotingStrategy

The objectQuotingStrategy attribute is used to control how object names are quoted in the SQL files generated by Liquibase and used in calls to the database. You can specify it as an attribute of the <databaseChangeLog> tag in your changelog or in individual changesets.

Uses

The database treats unquoted object names in SQL as case-insensitive by default. However, if you prefer to use case-sensitive object names or are using a reserved word like "table" as an object name, you must quote the names.

In Liquibase, there are three possible values for the objectQuotingStrategy attribute:

  • LEGACY – The default value. Does not quote objects unless the database specifies that they must be quoted. This may include reserved words and names containing special characters or spaces. In PostgreSQL databases, mixed-case names are also quoted.
  • QUOTE_ALL_OBJECTS – Every object gets quoted. For example, person becomes "person".
  • QUOTE_ONLY_RESERVED_WORDS – The same logic as LEGACY, but without mixed-case objects in PostgreSQL databases.

Tip: Databases may add new reserved words over time. For example, key may work as a table name until a new version of your database reserves key. In a later release, Liquibase also marks key as reserved. When you upgrade Liquibase, you must ensure your scripts can handle the new keyword being quoted.

Limitations

Liquibase can only use objectQuotingStrategy with simple object names. Liquibase cannot quote arbitrary blocks of SQL that are defined in a <sql> tag. Instead, quote the objects directly in the SQL you're sending to Liquibase.

objectQuotingStrategy also does not work on SQL in the references attribute of the <constraints> tag. Instead, you can use referencedTableName and referencedColumnName to specify the foreign key reference.

Syntax