ALTER VIEW

Function

ALTER VIEW modifies all auxiliary attributes of a view. (To modify the query definition of a view, use CREATE OR REPLACE VIEW.)

Precautions

Syntax

Parameter Description

Examples

Create an example view myview:

1
2
CREATE OR REPLACE VIEW myview AS
    SELECT * FROM pg_tablespace WHERE spcname = 'pg_default';

Rename a view.

1
ALTER VIEW myview RENAME TO product_view;

Change the schema of a view.

1
ALTER VIEW product_view SET schema public;

Rebuild a view.

1
ALTER VIEW public.product_view REBUILD;

Rebuild a dependent view.

1
ALTER VIEW ONLY public.product_view REBUILD;

Helpful Links

CREATE VIEW, DROP VIEW