ALTER MATERIALIZED VIEW (original) (raw)
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for thecurrent version, or one of the other supported versions listed above instead.
ALTER MATERIALIZED VIEW — change the definition of a materialized view
Synopsis
ALTER MATERIALIZED VIEW [ IF EXISTS ] name
action
[, ... ]
ALTER MATERIALIZED VIEW name
[ NO ] DEPENDS ON EXTENSION extensionname
ALTER MATERIALIZED VIEW [ IF EXISTS ] name
RENAME [ COLUMN ] columnname
TO newcolumnname
ALTER MATERIALIZED VIEW [ IF EXISTS ] name
RENAME TO newname
ALTER MATERIALIZED VIEW [ IF EXISTS ] name
SET SCHEMA newschema
ALTER MATERIALIZED VIEW ALL IN TABLESPACE name
[ OWNED BY rolename
[, ... ] ]
SET TABLESPACE newtablespace
[ NOWAIT ]
where action
is one of:
ALTER [ COLUMN ] _`columnname`_ SET STATISTICS _`integer`_
ALTER [ COLUMN ] _`columnname`_ SET ( _`attributeoption`_ = _`value`_ [, ... ] )
ALTER [ COLUMN ] _`columnname`_ RESET ( _`attributeoption`_ [, ... ] )
ALTER [ COLUMN ] _`columnname`_ SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT }
ALTER [ COLUMN ] _`columnname`_ SET COMPRESSION _`compressionmethod`_
CLUSTER ON _`indexname`_
SET WITHOUT CLUSTER
SET ACCESS METHOD _`newaccessmethod`_
SET TABLESPACE _`newtablespace`_
SET ( _`storageparameter`_ [= _`value`_] [, ... ] )
RESET ( _`storageparameter`_ [, ... ] )
OWNER TO { _`newowner`_ | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
Description
ALTER MATERIALIZED VIEW
changes various auxiliary properties of an existing materialized view.
You must own the materialized view to use ALTER MATERIALIZED VIEW
. To change a materialized view's schema, you must also have CREATE
privilege on the new schema. To alter the owner, you must be able to SET ROLE
to the new owning role, and that role must have CREATE
privilege on the materialized view's schema. (These restrictions enforce that altering the owner doesn't do anything you couldn't do by dropping and recreating the materialized view. However, a superuser can alter ownership of any view anyway.)
The statement subforms and actions available for ALTER MATERIALIZED VIEW
are a subset of those available for ALTER TABLE
, and have the same meaning when used for materialized views. See the descriptions for ALTER TABLE for details.
Parameters
name
The name (optionally schema-qualified) of an existing materialized view.
columnname
Name of an existing column.
extensionname
The name of the extension that the materialized view is to depend on (or no longer dependent on, if NO
is specified). A materialized view that's marked as dependent on an extension is automatically dropped when the extension is dropped.
newcolumnname
New name for an existing column.
newowner
The user name of the new owner of the materialized view.
newname
The new name for the materialized view.
newschema
The new schema for the materialized view.
Examples
To rename the materialized view foo
to bar
:
ALTER MATERIALIZED VIEW foo RENAME TO bar;
Compatibility
ALTER MATERIALIZED VIEW
is a PostgreSQL extension.