DROP DATABASE
Syntax
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 DROP
privilege 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 , "GRANT
Syntax".
IF EXISTS
is used to prevent an error from occurring if the database does not exist.
If the default database is dropped, the default database is unset (the DATABASE()
function returns NULL
).
If you use DROP DATABASE
on a symbolically linked database, both the link and the original database are deleted.
DROP DATABASE
returns the number of tables that were removed. This corresponds to the number of .frm
files removed.
The DROP DATABASE
statement removes from the given database directory those files and directories that MariaDB itself may create during normal operation:
- All files with the following extensions.
.BAK
.DAT
.HSH
.MRG
.MYD
.MYI
.TRG
.TRN
.db
.frm
.ibd
.ndb
.par
- The
db.opt
file, if it exists.
If other files or directories remain in the database directory after MariaDB removes those just listed, the database directory cannot be removed. In this case, you must remove any remaining files or directories manually and issue the DROP DATABASE
statement again.
You can also drop databases with mysqladmin. See , "mysqladmin - Client for Administering a MariaDB Server".