ALTER VIEW
Modifies the metadata of an existing view. The changes are auto-committed.
Syntax
General usage:
ALTER VIEW [[database.]schema.]view {
    | OWNER TO owner
    | SET SCHEMA schema
    | { INCLUDE | EXCLUDE | MATERIALIZE } [ SCHEMA ] PRIVILEGES
}
Rename view:
ALTER VIEW [[database.]schema.]view[,...] RENAME TO new-view-name[,...]
Parameters
- [- database- .]- schema
- Database and schema. The default schema is - public. If you specify a database, it must be the current database.
- view
- The view to alter.
- SET SCHEMA- schema``
- Moves the view from one schema to another.
- OWNER TO- owner
- Changes the view owner.
ImportantThe new view owner should also have SELECT privileges on the objects that the view references; otherwise the view is inaccessible to that user.
- 
{ 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] PRIVILEGESgrants 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 
 NoteIf inherited privileges are disabled at the database level, schema privileges can still be materialized.
- 
 
- 
- RENAME TO
- Renames one or more views:
RENAME TO new-view-name[,...]The following requirements apply: - 
The new view name conforms to conventions described in Identifiers. It must also be unique among all names of sequences, tables, projections, views, and models 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 USAGEandCREATEprivileges on the schema that contains the view.
 
- 
Privileges
Non-superuser: USAGE on the schema and one of the following:
- 
View owner 
- 
ALTER privilege on the view 
For certain operations, non-superusers must have the following schema privileges:
| Schema privileges required... | For these operations... | 
|---|---|
| CREATE, USAGE | Rename view | 
| CREATE: destination schema USAGE: current schema | Move view to another schema | 
Examples
Rename view view1 to view2:
=> CREATE VIEW view1 AS SELECT * FROM t;
CREATE VIEW
=> ALTER VIEW view1 RENAME TO view2;
ALTER VIEW