Skip to content

ALTER VIEW

Alter the attributes of an existing view.

ALTER VIEW [ IF EXISTS ] name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
ALTER VIEW [ IF EXISTS ] name RENAME TO new_name
ALTER VIEW [ IF EXISTS ] name SET SCHEMA new_schema
IF EXISTS
Alter the view if it exists, but do not return an error message if it does not exist.
OWNER TO
Change the owner of the view.
RENAME TO
Rename the view. The new name cannot be schema-qualified.
SET SCHEMA
Change the schema that the view belongs to.

For example, create a view and rename it:

premdb=# create view v1 as select * from season;
CREATE VIEW
premdb=# alter view v1 rename to season_view;
ALTER VIEW
premdb=# \d season_view
           View "public.season_view"
   Column    |         Type          | Modifiers 
-------------+-----------------------+-----------
 seasonid    | smallint              | 
 season_name | character(9)          | 
 numteams    | smallint              | 
 winners     | character varying(30) |

Parent topic:SQL Commands