swapDatabase

Atomically swaps the contents of two databases in Snowflake. This operation exchanges all schemas, tables, and objects between the databases in a single transaction.

Note: Automatic rollback swaps the databases back.

Known limitation: This change type does not support database inspection features (snapshot, diff, diff-changelog, and generate-changelog commands).

Available attributes

Attribute

Type

Description

Required

databaseName

String

Name of the first database to swap

Yes

targetDatabaseName

String

Name of the second database to swap with

Yes

ifExists

Boolean

Only execute if both databases exist

No

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Basic swap -->
  <changeSet id="swap-database-basic" author="examples">
    <pro-snowflake:swapDatabase
            databaseName="DATABASE_A"
            targetDatabaseName="DATABASE_B"/>
  </changeSet>
  <!-- Swap with IF EXISTS -->
  <changeSet id="swap-database-if-exists" author="examples">
    <pro-snowflake:swapDatabase
            databaseName="DATABASE_A"
            targetDatabaseName="DATABASE_B"
            ifExists="true"/>
  </changeSet>
</databaseChangeLog>

More like this

Rename a database

Create a new database

Clone an existing database

Official Snowflake documentation