DROP DATABASE
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 the given database with all its tables and data.
USAGE
Common Syntax:
DROP {DATABASE | SCHEMA} [IF EXISTS] <db_name>
DETAILS
The DROP DATABASE
statement irreversibly deletes the database. All tables and data are removed. A dropped database can only be recovered by restoring a backup.
EXAMPLES
DROP DATABASE
To delete a database:
DROP DATABASE db1;
IF EXISTS
By default, if you try to delete a database that does not exist, an error is raised.
To prevent an error when the specified database is not present, add the IF EXISTS
clause:
DROP DATABASE IF EXISTS db1;
If the specified database exists, it will be deleted. If the specified database does not exist, the query does not raise an error.