What is the correct syntax to alter the table and adding multiple columns at a time using liquibase xml. The official document gives the example for adding only one column :
<changeSet author="liquibase-docs" id="addColumn-example">
<addColumn catalogName="cat"
schemaName="public"
tableName="person">
<column name="address" type="varchar(255)"/>
</addColumn>
</changeSet>
Now if I want to add multiple columns at a time, what is the correct syntax:
<changeSet author="liquibase-docs" id="addColumn-example">
<addColumn catalogName="cat"
schemaName="public"
tableName="person">
<column name="job" type="varchar(255)"/>
</addColumn>
<addColumn catalogName="cat"
schemaName="public"
tableName="person">
<column name="designation" type="varchar(255)"/>
</addColumn>
</changeSet>
Is it correct or
<changeSet author="liquibase-docs" id="addColumn-example">
<addColumn catalogName="cat"
schemaName="public"
tableName="person">
<column name="job" type="varchar(255)"/>
<column name="designation" type="varchar(255)"/>
</addColumn>
</changeSet>
which is correct of the two above? or something different altogether.
You can add multiple columns to an SQL table using the ALTER TABLE syntax. To do so, specify multiple columns to add after the ADD keyword. Separate each column you want to add using a comma.
I recently needed to add multiple columns to an existing table to store summary data calculations and wondered if I could do it in one MySQL ALTER TABLE statement. Turns out you can. And, it's super simple.
The changeset tag is a unit of change that Liquibase executes on a database and which is used to group database Liquibase Change Types together. A list of changes created by multiple changesets are tracked in a changelog.
Both of those examples will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With