Skip to main content

ALTER MATERIALIZED VIEW

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

Syntax

ALTER MATERIALIZED VIEW materialized_view_name 
alter_option;

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

Clause

OWNER TO

Syntax
ALTER MATERIALIZED VIEW materialized_view_name
OWNER TO new_user;
Parameter or clauseDescription
OWNER TOThis clause changes the owner of the materialized view. Note that this will cascadingly change all related internal objects as well.
new_userThe new owner you want to assign to the materialized view.
Example
-- Change the owner of the materialized view named "materialized_view1" to user "user1"
ALTER MATERIALIZED VIEW materialized_view1 OWNER TO user1;

SET SCHEMA

Syntax
ALTER MATERIALIZED VIEW materialized_view_name
SET SCHEMA schema_name;
Parameter or clauseDescription
SET SCHEMAThis clause moves the materialized view to a different schema.
schema_nameThe name of the schema to which the materialized view will be moved.
Example
-- Move the materialized view named "test_materialized_view" to the schema named "test_schema"
ALTER MATERIALIZED VIEW test_materialized_view SET SCHEMA test_schema;

RENAME TO

Syntax
ALTER MATERIALIZED VIEW materialized_view_name
RENAME TO new_name;
Parameter or clauseDescription
RENAME TOThis clause changes the name of the materialized view.
new_nameThe new name of the materialized view.
Example
-- Change the name of the materialized view named "mv_1" to "mv_2"
ALTER MATERIALIZED VIEW mv_1 RENAME TO mv_2;

Help us make this doc better!

Was this page helpful?

Happy React is loading...