ALTER VIEW
On this page
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>
AS <select_statement>Remarks
-
ALTER VIEWatomically replaces view<view_with a new view defined byname> <select_.statement> -
ALTER VIEWprivileges are granted only to the designer of the view and toSUPERusers.If a SUPERuser alters a view, that user commandeersALTERprivileges from the designer of the view. -
The
DEFINERclause (ALTER DEFINER = <user>@<host> VIEW <viewname> AS SELECT .) specifies the user that should be used for security checks when a view is referenced by a query.. . The default value is CURRENT_.USER -
When
SCHEMA_is set toBINDING ON, 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_is set toBINDING OFF. -
The user who runs
ALTER DEFINER.must have the. VIEW SUPERpermission. -
Refer to the Permission Matrix for the required permissions.
Examples
ALTER VIEW view_name AS SELECT * FROM table_name WHERE user_id = "real_person";
Related Topics
Last modified: March 7, 2025