DROP TABLE
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 table and the data it contains from the database.
USAGE
Common Syntax:
DROP [TEMPORARY] TABLE [IF EXISTS] <tbl_name> [, <tbl_name>] ...
EXAMPLES
DROP TABLE
To delete a table in the currently selected database:
DROP TABLE tbl1;
The built-in function DATABASE()
returns the currently selected database.
To explicitly specify a database from which to delete a table, use the DATABASE_NAME.TABLE_NAME
notation:
DROP TABLE db1.tbl1;
IF EXISTS
By default, if you try to delete a table that does not exist, an error is raised.
To prevent an error when the specified table is not present, add the IF EXISTS
clause:
DROP TABLE IF EXISTS tbl1;
If the specified table exists, it will be deleted. If the specified table does not exist, the query does not raise an error.
DROP TEMPORARY TABLE
To delete a temporary table:
DROP TEMPORARY TABLE tbl1;
Delete Multiple Tables
To delete multiple tables at once, specify the names separated by commas:
DROP TABLE db1.tbl1, db2.tbl1, db3.tbl1;
If some of the tables in the argument list do not exist, MariaDB Xpand will drop the tables that do exist and return an error listing non-existing tables it was unable to drop.