CREATE VIEW

    Where query is a SELECT statement.

    CREATE VIEW creates a named definition of a query. This name can be used in other statements instead of a table name to reference the saved query definition. A view is not materialized, instead the query is run every time a view is referenced in a query.

    If is used, an already existing view with the same name will be replaced.

    Table and view names must be unique within a schema. A view cannot have the name of an already existing table.

    Views are read-only. They cannot be used as a target relation in write operations.

    See also

    Note

    If a * is used to select the columns within the views query definition, this will be resolved at query time like the rest of the query definition. This means if columns are added to the table after the view had been created, these columns will show up in subsequent queries on the view. It is generally recommended to avoid using * in view definitions.

    Regular users need to have DDL permissions on the schema in which the view is being created. In addition the user creating the view requires DQL permissions on all relations that occur within the views query definition.