addLookupTable
Creates a lookup table containing values stored in a column and creates a foreign key to the new table.
Run addLookupTable
To run this Change Type, follow these steps:
Add the Change Type to your changeset, as shown in the examples on this page.
Specify any required attributes. Use the table on this page to see which ones your database requires.
Deploy your changeset by running the
update
command:liquibase update
Available attributes
Name | Description | Required for | Supports |
| Name of the constraint ( | all | |
| Name of the column containing the data to extract | all | all |
| Name of the catalog of the existing table | all | |
| Name of the table containing the data to extract | all | all |
| Name of the schema of the existing table | all | |
| Data type of the column. To help make scripts database-independent, Liquibase automatically converts the following generic data types to the correct database implementation: Also, specifying a
For Snowflake, Liquibase also implements For Databricks, Liquibase also implements Note: To specify a complex Databricks type like For more information, see Liquibase Data Type Handling. | Informix, MariaDB, mssql, mysql | all |
| Name of the column in the new table to create | all | all |
| Name of the catalog of the table to create | all | |
| Name of the table to create | all | all |
| Name of the schema of the table to create | all |
Database support
Database | Notes | |
DB2/LUW | Supported | Yes |
DB2/z | Supported | Yes |
Derby | Supported | Yes |
Firebird | Not Supported | No |
Google BigQuery | Supported | Yes |
H2 | Supported | Yes |
HyperSQL | Not Supported | No |
INGRES | Supported | Yes |
Informix | Supported | Yes |
MariaDB | Supported | Yes |
MySQL | Supported | Yes |
Oracle | Supported | Yes |
PostgreSQL | Supported | Yes |
Snowflake | Supported | Yes |
SQL Server | Supported | Yes |
SQLite | Not Supported | No |
Sybase | Supported | Yes |
Sybase Anywhere | Supported | Yes |
addLookupTable examples
liquibase formatted SQL
--changeset liquibase-docs:addLookupTable-example
CREATE TABLE cat.state AS
SELECT DISTINCT
state AS abbreviation
FROM
address
WHERE
state IS NOT NULL;
ALTER TABLE public.state MODIFY abbreviation CHAR(2) NOT NULL;
ALTER TABLE public.state ADD PRIMARY KEY (abbreviation);
ALTER TABLE address ADD CONSTRAINT fk_address_state FOREIGN KEY (state) REFERENCES public.state (abbreviation);