Liquibase® version 3.8.5 is now available! Get it for free.
2018 XML Announcement
News All Previous Posts >>

Subscribe for email updates

- and/or -

Change: ‘createView’

Create a new database view

Available Attributes

NameDescriptionRequired ForSupportsSince
catalogNameName of the catalogall3.0
encodingall
fullDefinitionSet to true if selectQuery is the entire view definition. False if the CREATE VIEW header should be addedall3.3
pathPath to file containing view definitionall3.6
relativeToChangelogFileall
remarksall
replaceIfExistsUse 'create or replace' syntaxdb2, firebird, h2, hsqldb, ingres, mariadb, mssql, mysql, oracle, postgresql, sqlite, sybase1.5
schemaNameName of the schemaall
selectQuerySQL for generating the viewinformixall
viewNameName of the view to createallall
<changeSet author="liquibase-docs" id="createView-example">
    <createView catalogName="cat"
            encoding="UTF-8"
            fullDefinition="true"
            path="A String"
            relativeToChangelogFile="true"
            remarks="A String"
            replaceIfExists="false"
            schemaName="public"
            viewName="v_person">select id, name from person where id > 10</createView>
</changeSet>
changeSet:
  id: createView-example
  author: liquibase-docs
  changes:
  - createView:
      catalogName: cat
      encoding: UTF-8
      fullDefinition: true
      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": true,
          "path": "A String",
          "relativeToChangelogFile": true,
          "remarks": "A String",
          "replaceIfExists": false,
          "schemaName": "public",
          "selectQuery": "select id, name from person where id > 10",
          "viewName": "v_person"
        }
      }]
    
  }
}

SQL Generated From Above Sample (MySQL)

CREATE VIEW cat.v_person AS select id,
 name from person where id > 10;

Database Support

DatabaseNotesAuto Rollback
DB2SupportedYes
DB2SupportedYes
DerbySupportedYes
FirebirdSupportedYes
H2SupportedYes
HyperSQLSupportedYes
INGRESSupportedYes
InformixSupportedYes
MariaDBSupportedYes
MySQLSupportedYes
OracleSupportedYes
PostgreSQLSupportedYes
SQL ServerSupportedYes
SQLiteSupportedYes
SybaseSupportedYes
Sybase AnywhereSupportedYes