Appearance
ALTER VIEW
Alter the attributes of an existing view.
console
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
ALTER VIEW [ IF EXISTS ] name SET REPRESENTATION {DEFAULT | TEXT | BINARY}
- 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.
- SET REPRESENTATION
- Change the view representaion to use the default configuration, text storage or binary storage.
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) |