createView
Creates a new database view.
Available attributes
Name | Description | Required for | Supports |
---|---|---|---|
catalogName
|
Name of the catalog | all | |
encoding
|
Encoding used in the file defined in the path attribute |
all | |
fullDefinition
|
Set to true if selectQuery is the entire view definition. False if the CREATE VIEW header should be added |
all | |
path
|
Path to file containing view definition. Using the path attribute is an alternative to selectQuery . |
all | |
relativeToChangelogFile
|
Whether the file path relative to the changelog file rather than looked up in the search path. | all | |
remarks
|
Comments stored for the view | all | |
replaceIfExists
|
Use 'create or replace' syntax | db2, firebird, h2, hsqldb, ingres, mariadb, mssql, mysql, oracle, postgresql, sqlite, sybase | |
schemaName
|
Name of the schema | all | |
selectQuery
|
SQL for generating the view | informix | all |
viewName
|
Name of the view to create | all | all |

To apply the selectQuery
value in XML, set it as a body of the tag:
<changeSet author="liquibase-docs" id="createView-example">
<createView catalogName="cat"
encoding="UTF-8"
fullDefinition="false"
remarks="A String"
replaceIfExists="false"
schemaName="public"
viewName="v_person">select id, name from person where id > 10</createView>
</changeSet>
Using the path
attribute is an alternative to selectQuery
:
<changeSet author="liquibase-docs" id="createView-example">
<createView catalogName="cat"
encoding="UTF-8"
path="A String"
relativeToChangelogFile="true"
remarks="A String"
replaceIfExists="false"
schemaName="public"
viewName="v_person"></createView>
</changeSet>

changeSet:
id: createView-example
author: liquibase-docs
changes:
- createView:
catalogName: cat
encoding: UTF-8
fullDefinition: false
path: A String
relativeToChangelogFile: true
remarks: A String
replaceIfExists: false
schemaName: public
selectQuery: select id, name from person where id > 10
viewName: v_person

{
"changeSet":
{
"id": "createView-example",
"author": "liquibase-docs",
"changes": [
{
"createView":
{
"catalogName": "cat",
"encoding": "UTF-8",
"fullDefinition": false,
"path": "A String",
"relativeToChangelogFile": true,
"remarks": "A String",
"replaceIfExists": false,
"schemaName": "public",
"selectQuery": "select id, name from person where id > 10",
"viewName": "v_person"
}
}]
}
}

CREATE VIEW cat.v_person AS select id,
name from person where id > 10;
Database support
Database | Notes | Auto rollback |
---|---|---|
DB2/LUW | Supported | Yes |
DB2/z | Supported | Yes |
Derby | Supported | Yes |
Firebird | Supported | Yes |
H2 | Supported | Yes |
HyperSQL | Supported | Yes |
INGRES | Supported | Yes |
Informix | Supported | Yes |
MariaDB | Supported | Yes |
MySQL | Supported | Yes |
Oracle | Supported | Yes |
PostgreSQL | Supported | Yes |
Snowflake | Supported | Yes |
SQL Server | Supported | Yes |
SQLite | Supported | Yes |
Sybase | Supported | Yes |
Sybase Anywhere | Supported | Yes |