mergeColumns
The mergeColumns
Change Type concatenates the values in two columns and joins them with a string. The Change Type stores the resulting value in a new column.
Uses
You can typically use the mergeColumns
Change Type when you want to combine the values from two columns into one.
Running the mergeColumns
Change Type
To merge your data in one column, follow these steps:
Step 1: Add the mergeColumns
Change Type to your changeset with the needed attributes as it is shown in the examples.
Step 2: Deploy your changeset by running the update
command.
liquibase update
Now, you should see a new merged column.
Available attributes
Name | Description | Required for | Supports |
---|---|---|---|
catalogName
|
The name of the catalog | all | |
column1Name
|
The name of the column containing the first half of the data | all | all |
column2Name
|
The name of the column containing the second half of the data | all | all |
finalColumnName
|
The name of the column to create | all | all |
finalColumnType
|
The data type of the column to create | all | all |
joinString
|
The string to place between the values from column1 and column2 (may be empty) |
all | |
schemaName
|
The name of the schema | all | |
tableName
|
The name of the table containing the columns to join | all | all |

<changeSet author="liquibase-docs" id="mergeColumns-example">
<mergeColumns catalogName="cat"
column1Name="first_name"
column2Name="last_name"
finalColumnName="full_name"
finalColumnType="varchar(255)"
joinString="A String"
schemaName="public"
tableName="person"/>
</changeSet>

changeSet:
id: mergeColumns-example
author: liquibase-docs
changes:
- mergeColumns:
catalogName: cat
column1Name: first_name
column2Name: last_name
finalColumnName: full_name
finalColumnType: varchar(255)
joinString: A String
schemaName: public
tableName: person

{
"changeSet":{
"id":"mergeColumns-example",
"author":"liquibase-docs",
"changes":[
{
"mergeColumns":{
"catalogName":"cat",
"column1Name":"first_name",
"column2Name":"last_name",
"finalColumnName":"full_name",
"finalColumnType":"varchar(255)",
"joinString":"A String",
"schemaName":"public",
"tableName":"person"
}
}
]
}
}

ALTER TABLE public.person ADD full_name VARCHAR(255) NULL;
UPDATE cat.person SET full_name = CONCAT_WS('A String',
first_name,last_name);
ALTER TABLE public.person DROP COLUMN first_name;
ALTER TABLE public.person DROP COLUMN last_name;
Database support
Database | Notes | Auto rollback |
---|---|---|
DB2/LUW | Supported | No |
DB2/z | Not Supported | No |
Derby | Not Supported | No |
Firebird | Supported | No |
H2 | Supported | No |
HyperSQL | Supported | No |
INGRES | Supported | No |
Informix | Supported | No |
MariaDB | Supported | No |
MySQL | Supported | No |
Oracle | Supported | No |
PostgreSQL | Supported | No |
Snowflake | Supported | No |
SQL Server | Supported | No |
SQLite | Supported | No |
Sybase | Supported | No |
Sybase Anywhere | Supported | No |