Skip to main content

ALTER VIEW

The ALTER VIEW command modifies the definition of a view. To use this command, you must own the view.

Syntax

ALTER VIEW view_name 
alter_option;

alter_option depends on the operation you want to perform on the view. For all supported clauses, see the sections below.

Clause

OWNER TO

ALTER VIEW view_name
OWNER TO new_user;
Parameter or clauseDescription
OWNER TOThis clause changes the owner of the view.
new_userThe new owner you want to assign to the view.
-- Change the owner of the view named "view1" to user "user1"
ALTER VIEW view1 OWNER TO user1;

SET SCHEMA

ALTER VIEW view_name
SET SCHEMA schema_name;
Parameter or clauseDescription
SET SCHEMAThis clause moves the view to a different schema.
schema_nameThe name of the schema to which the view will be moved.
-- Move the view named "test_view" to the schema named "test_schema"
ALTER VIEW test_view SET SCHEMA test_schema;

RENAME TO

ALTER VIEW view_name
RENAME TO new_name;
Parameter or clauseDescription
RENAME TOThis clause changes the name of the view.
new_nameThe new name of the view.
-- Change the name of the view named "view1" to "view2"
ALTER VIEW view1 RENAME TO view2;

Help us make this doc better!