The command DROP DATABASE per­man­ently deletes entire databases in MariaDB. Therefore, the command requires the DROP privilege on the database concerned and should be used with great caution.

DROP DATABASE in MariaDB

DROP DATABASE is a very effective statement for MariaDB, which should only be used extremely carefully. It is used to delete a database from a server structure. Once the command has been executed, the entire database including all tables and data is ir­re­triev­ably lost and can no longer be accessed. Only user rights that were es­tab­lished when using MariaDB CREATE USER are not auto­mat­ic­ally revoked. In MariaDB, DROP DATABASE requires the DROP privilege on the database concerned. Other commands such as DELETE DATABASE for MariaDB or REMOVE DATABASE for MariaDB do not exist.

Managed Databases
Time-saving database services
  • En­ter­prise-grade ar­chi­tec­ture managed by experts
  • Flexible solutions tailored to your re­quire­ments
  • Hosted in the UK under strict data pro­tec­tion le­gis­la­tion

Syntax with and without IF EXISTS

The syntax of DROP DATABASE in MariaDB is as follows:

DROP DATABASE Name_of_database;
sql

Replace the place­hold­er ‘Name_of_database’ with the name of the specific database you want to delete.

You can op­tion­ally include IF EXISTS to avoid receiving an error message if the database is not found on your server.

DROP DATABASE IF EXISTS Name_of_database;
sql

How does DROP DATABASE in MariaDB work?

To il­lus­trate how DROP DATABASE works in MariaDB, we will use a simple example. Let’s imagine that a database called ‘Tasks_2023’ is no longer needed. Therefore, we use SHOW DATABASES to check if the database is still on the server and then remove it. This is the code:

mysql> SHOW DATABASES;
mysql> DROP DATABASE Tasks_2023;
sql
Tip

In our Digital Guide we also reveal how to create a new database with MariaDB CREATE DATABASE and how to call up a database with MariaDB SELECT DATABASE. You will also find a MariaDB and MySQL com­par­is­on and learn everything you need to know about in­stalling MariaDB.

Reviewers

Go to Main Menu