Applies to:
- Liquibase Pro
- Liquibase Open Source (Community)
Summary:
If you want to create a schema that doesn't already exist, you can do this with Liquibase in two ways: using formatted SQL or an XML changelog with the SQL tag.
Environment Conditions:
Only available on the following databases:
DB2/LUW, DB2/z, Derby, Firebird, H2, HyperSQL, INGRES, Informix, MariaDB, MySQL, Oracle, PostgreSQL, Snowflake, SQL Server, SQLite, Sybase, Sybase Anywhere.
How to Create a New Schema
Formatted SQL
-- liquibase formatted sql
-- changeset liquibase:1
CREATE SCHEMA schemaName;
-- rollback DROP SCHEMA schemaName
XML Changelog
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
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/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">
<changeSet id="1" author="Liquibase">
<sql>
CREATE SCHEMA schemaName;
</sql>
</changeSet>
</databaseChangeLog>
Note: The SQL change type in XML changesets does not have an auto rollback.
Comments
0 comments
Article is closed for comments.