0 votes
in MariaDB by
How to delete a database in MariadB ?

1 Answer

0 votes
by

DROP DATABASE command is used to drop a database in MariB. Be very careful with this statement! To use a DROP DATABASE, you need to DROP privileges on the database. DROP SCHEMA is a synonym for DROP DATABASE

NOTE: When a database is dropped, user privileges on the database are not automatically

Syntax:

DROP DATABASE Database_name;   

IF EXISTS statement:

Use IF EXISTS to prevent an error from occurring for the database that does not exist. A note is generated for each non-existent database when using IF EXISTS statement.

Example

DROP DATABASE student;  

Output:

Query OK, 0 rows affected (0.39 sec) 

DROP DATABASE student;  

Output:

ERROR (1008): can't drop database; database doesn't exists [\]w: show warning enabled

DROP DATABASE IF EXISTS student;  

Output:

Query OK, 0 rows affected, 1 warning (0.00 sec)

Note (code 1008): can't drop database 'student'; database doesn't exists

...