Concatenates the values in two columns, joins them by with string, and stores the resulting value in a new column.
| Name | Description |
|---|---|
| catalogName | Name of the catalogE.g. 'cat' |
| column1Name | Name of the column containing the first half of the dataE.g. 'first_name' |
| column2Name | Name of the column containing the second half of the dataE.g. 'last_name' |
| finalColumnName | Name of the column to createE.g. 'full_name' |
| finalColumnType | Data type of the column to createE.g. 'varchar(255)' |
| joinString | String to place include between the values from column1 and column2 (may be empty)E.g. 'A String' |
| schemaName | Name of the schemaE.g. 'public' |
| tableName | Name of the table containing the columns to joinE.g. 'person' |
<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(first_name,
'A String',
last_name);
ALTER TABLE public.person DROP COLUMN first_name;
ALTER TABLE public.person DROP COLUMN last_name;| 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 |
| SQL Server | Supported | No |
| SQLite | Supported | No |
| Sybase | Supported | No |
| Sybase Anywhere | Supported | No |