CREATE VIEW creates a new view in an existing database. A view is a virtual table.


  • Use views to simplify complex queries or present only partial data to specific roles.
  • If an underlying table has changed (new columns, changed names, etc.) - a view may be invalidated. To recompile the view, see SELECT RECOMPILE_VIEW(<view name>)


The role must have the CREATE permission at the database level, as well as SELECT permissions for any tables referenced by the view.


create_view_statement ::=
    CREATE [ OR REPLACE ] VIEW [schema_name].view_name [ column_list ]

schema_name ::= identifier

view_name ::= identifier

column_list ::= ( { column_name [, ...] } )

column_name ::= identifier


Parameter Description
OR REPLACE Create a new view, and overwrite any existing views by the same name. Does not return an error if the view already exists.
schema_name The name of the schema in which to create the view.
view_name The name of the view to create, which must be unique inside the schema.
column_list An optional comma separated list of column names for the view. If specified, these column names will override the column names in the response of the query in the AS query statement.
AS query The select query to execute when the view is referenced.


A simple view

CREATE VIEW only_agressive_animals AS
  SELECT * FROM cool_animals WHERE is_agressive=true;

SELECT * FROM only_agressive_animals;

Overriding default column names

CREATE VIEW only_relaxed_animals (animal_id, animal_name, should_i_worry) AS
  SELECT id, name, is_agressive FROM cool_animals WHERE is_agressive=false;