ALTER VIEW

Modifies the metadata of an existing view. The changes are auto-committed

Syntax

Parameters

schema

Specifies a schema. If multiple schemas are defined in the database, include the schema name. For example:

myschema.thisDbObject
view-name

The view to alter.

SET SCHEMA schema‑name Moves the view from one schema to another.
OWNER TO owner‑name

Changes the view owner.

{ INCLUDE
| EXCLUDE 
| MATERIALIZE }
[SCHEMA] PRIVILEGES

Specifies default inheritance of schema privileges for this view:

  • EXCLUDE [SCHEMA] PRIVILEGES (default) disables inheritance of privileges from the schema.
  • INCLUDE [SCHEMA] PRIVILEGES grants the view the same privileges granted to its schema. 
  • MATERIALIZE: Copies grants to the view and creates a GRANT object on the view. This disables the inherited privileges flag on the view, so you can:
    • Grant more specific privileges at the view level
    • Use schema-level privileges as a template
    • Move the view to a different schema
    • Change schema privileges without affecting the view
  • Note: If inherited privileges are disabled at the database level, schema privileges can still be materialized.

For more information see Grant Inherited Privileges.

RENAME TO

Renames one or more views:

RENAME TO new‑view‑name[,...]

The following requirements apply:

  • The new view name must be unique among all tables, views and projections within the same schema.
  • If you specify multiple views to rename, the source and target lists must have the same number of names.
  • Renaming a view requires USAGE and CREATE privileges on the schema that contains the view.

Privileges

Changing a view requires the following privileges:

Example

The following command renames view1 to view2:

=> CREATE VIEW view1 AS SELECT * FROM t;
CREATE VIEW
=> ALTER VIEW view1 RENAME TO view2;
ALTER VIEW