Outdated Version
You are viewing an older version of this section. View current production version.
ALTER VIEW
Atomically replace a view with a new view defined by a SELECT statement. ALTER VIEW is an online operation and will not cause concurrently executing queries to fail.
Syntax
ALTER
[DEFINER = { user | CURRENT_USER }]
[SCHEMA_BINDING = { ON | OFF }]
VIEW view_name [(column_list)]
AS select_statement
Remarks
ALTER VIEWatomically replaces viewview_namewith a new view defined byselect_statement.ALTER VIEWprivileges are granted only to the user who created the view and toSUPERusers. If aSUPERuser alters a view, that user commandeersALTERprivileges from the user who created the view.- The
DEFINERclause specifies the user that should be used for security checks when a view is referenced by a query. The default value isCURRENT_USER. - When
SCHEMA_BINDINGis set toON, objects referenced by the view cannot be dropped if the view exists; you need to drop the view before dropping these objects. By default,SCHEMA_BINDINGis set toOFF. - The user who runs
ALTER DEFINER..VIEWmust have theSUPERpermission.
Examples
ALTER VIEW view_name AS SELECT * FROM table_name WHERE user_id = "real_person";
Related Topics