ALTER VIEW modifies all auxiliary attributes of a view. (To modify the query definition of a view, use CREATE OR REPLACE VIEW.)
1 2 | ALTER VIEW [ IF EXISTS ] view_name ALTER [ COLUMN ] column_name SET DEFAULT expression; |
1 2 | ALTER VIEW [ IF EXISTS ] view_name ALTER [ COLUMN ] column_name DROP DEFAULT; |
1 2 | ALTER VIEW [ IF EXISTS ] view_name OWNER TO new_owner; |
1 2 | ALTER VIEW [ IF EXISTS ] view_name RENAME TO new_name; |
1 2 | ALTER VIEW [ IF EXISTS ] view_name SET SCHEMA new_schema; |
1 2 | ALTER VIEW [ IF EXISTS ] view_name SET ( { view_option_name [ = view_option_value ] } [, ... ] ); |
1 2 | ALTER VIEW [ IF EXISTS ] view_name RESET ( view_option_name [, ... ] ); |
1 2 | ALTER VIEW [ IF EXISTS ] view_name REBUILD; |
1 2 | ALTER VIEW ONLY [ IF EXISTS ] view_name REBUILD; |
If this option is specified, no error is reported if the view does not exist. Only a message is displayed.
Specifies the view name, which can be schema-qualified.
Value range: a string. It must comply with the naming convention.
Indicates an optional list of names to be used for columns of the view. If not given, the column names are deduced from the query.
Value range: a string. It must comply with the naming convention.
Sets or deletes the default value of a column. Currently, this parameter does not take effect.
Specifies the new owner of a view.
Specifies the new view name.
Specifies the new schema of the view.
This clause specifies optional parameters for a view.
Currently, the only parameter supported by view_option_name is security_barrier, which should be enabled when a view is intended to provide row-level security.
Value range: boolean type. It can be TRUE or FALSE.
Only views and their dependent views are rebuilt. This function is available only if view_independent is set to on.
Rename a view.
1 | ALTER VIEW tpcds.customer_details_view_v1 RENAME TO customer_details_view_v2; |
Change the schema of a view.
1 | ALTER VIEW tpcds.customer_details_view_v2 SET schema public; |
Rebuild a view.
1 | ALTER VIEW public.customer_details_view_v2 REBUILD; |
Rebuild a dependent view.
1 | ALTER VIEW ONLY public.customer_details_view_v2 REBUILD; |