arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

DROP DATABASE

Complete guide to removing databases in MariaDB. Complete DROP DATABASE syntax with IF EXISTS, permissions, and recovery options for production use.

hashtag
Syntax

DROP {DATABASE | SCHEMA} [IF EXISTS] db_name

hashtag
Description

DROP DATABASE drops all tables in the database and deletes the database. Be very careful with this statement! To use DROP DATABASE, you need the on the database. DROP SCHEMA is a synonym for DROP DATABASE.

Important: When a database is dropped, user privileges on the database are not automatically dropped. See .

hashtag
IF EXISTS

Use IF EXISTS to prevent an error from occurring for databases that do not exist. A NOTE is generated for each non-existent database when using IF EXISTS. See .

hashtag
Atomic DDL

supports .DROP DATABASE is implemented as

Each individual is atomic while DROP DATABASE as a whole is crash-safe.

Atomic DROP is not available.

hashtag
Examples

hashtag
See Also

This page is licensed: GPLv2, originally from

SHOW CREATE DATABASE

DROP DATABASE bufg;
Query OK, 0 rows affected (0.39 sec)

DROP DATABASE bufg;
ERROR 1008 (HY000): Can't drop database 'bufg'; database doesn't exist

 \W
SHOW warnings enabled.

DROP DATABASE IF EXISTS bufg;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Note (Code 1008): Can't DROP DATABASE 'bufg'; DATABASE doesn't exist
DROP privilege
GRANT
SHOW WARNINGS
Atomic DDL
DROP TABLE
CREATE DATABASE
ALTER DATABASE
SHOW DATABASES
Information Schema SCHEMATA Table
fill_help_tables.sqlarrow-up-right
LOOP OVER ALL tables
  DROP TABLE tbl
spinner
MariaDB 10.6.1