ALTER VIEW
Modifies the metadata of an existing view. The changes are auto-committed.
Syntax
ALTER VIEW [[database.]schema.]view { | OWNER TO owner | SET SCHEMA schema | { INCLUDE | EXCLUDE | MATERIALIZE } [ SCHEMA ] PRIVILEGES }
ALTER VIEW [[database.]schema.]view[,…] RENAME TO new-view-name[,…]
Parameters
[database.]schema
|
Specifies a schema, by default myschema.thisDbObject 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. The new view owner should also have SELECT privileges on the objects that the view references; otherwise the view is inaccessible to that user. |
{ INCLUDE
|
Specifies default inheritance of schema privileges for this view:
If inherited privileges are disabled at the database level, schema privileges can still be materialized. See also Setting Privileges Inheritance on Tables and Views in the Administrator's Guide. |
RENAME TO
|
Renames one or more views: RENAME TO new‑view‑name[,…]
The following requirements apply:
|
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 |
Move view to another schema |
Example
Rename view view1
to view2
:
=> CREATE VIEW view1 AS SELECT * FROM t; CREATE VIEW => ALTER VIEW view1 RENAME TO view2; ALTER VIEW