DROP VIEW
This page is part of MariaDB's Documentation.
The parent of this page is: SQL Statements for MariaDB Xpand
Topics on this page:
Overview
Deletes a view of the database.
USAGE
Common Syntax:
DROP VIEW [IF EXITS] <xpand_view_name> [, <xpand_view_name>] ...
Supported Syntax:
DROP {TABLE | VIEW} [IF EXITS] <xpand_view_name> {, <xpand_view_name>} ...
EXAMPLES
DROP VIEW
To delete a view in the currently selected database:
DROP VIEW view1;
The built-in function DATABASE()
returns the currently selected database.
To explicitly specify a database from which to delete a view, use the DATABASE_NAME.VIEW_NAME
notation:
DROP VIEW db1.view1;
IF EXISTS
By default, if you try to delete a view that does not exist, an error is raised.
To prevent an error when the specified view is not present, add the IF EXISTS
clause:
DROP VIEW IF EXISTS view1;
If the specified view exists, it will be deleted. If the specified view does not exist, the query does not raise an error.
Delete Multiple Views
To delete multiple views at once, specify the names separated by commas:
DROP VIEW db1.view1, db2.view1, db3.view1;
If some of the views in the argument list do not exist, MariaDB Xpand returns an error listing non-existing views it was unable to drop, and no existing views named in the argument list get deleted.