# How to delete databases permanently with SQL DATABASE

SQL `DROP DATABASE` is used to permanently delete an entire database including all tables and entries. The [SQL command](https://www.ionos.com/digitalguide/server/configuration/sql-commands/) should therefore only be used if the database is actually no longer required or corresponding backups exist. It is also possible to remove several databases at the same time.

## What is SQL DROP DATABASE?

When working with [Structured Query Language](https://www.ionos.com/digitalguide/server/configuration/sql-introduction-with-examples/), your initial steps typically involve creating a new database using [SQL CREATE DATABASE](https://www.ionos.com/digitalguide/server/configuration/sql-create-database/). Next, create one or more tables with [SQL CREATE TABLE](https://www.ionos.com/digitalguide/server/configuration/sql-create-table/), which you can then fill with data. To prevent obsolete databases from occupying storage space or **potentially leaving sensitive data unprotected**, it’s important to delete them when they are no longer needed. For this, SQL provides the SQL `DROP DATABASE` command, which removes the entire database and all its connections.

It is important that you take the necessary precautions in advance. Once a database has been deleted with this command, all data is **irretrievably lost**. Therefore, make sure that you create [backups](https://www.ionos.com/digitalguide/server/security/what-is-a-backup/) using the [SQL BACKUP DATABASE](https://www.ionos.com/digitalguide/server/configuration/sql-backup-database/) command. You should also make sure that no important programs or processes rely on the database. The deletion process typically can only be executed by an administrator. Therefore, if you want to use the SQL `DROP DATABASE` command, you’ll need the necessary permissions.

## Syntax and function

The syntax of SQL `DROP DATABASE` is as follows:

```sql
DROP DATABASE name_of_database;
```

You only need to insert the name of the corresponding database and execute the code. This will remove the database, along with all its tables and entries, making it inaccessible.

## Example of the deletion process

In practice, SQL DROP DATABASE command might look like this. Suppose we have a database called “Customers,” but its entries are outdated. Since we’ve already created a new database with the necessary data, we want to remove the entire old database rather than deleting each table individually. The command would be:

```sql
DROP DATABASE Customers;
```

## Combination with IF EXISTS

If you’re unsure whether a particular database exists, you can use SQL `DROP DATABASE` with the `IF EXISTS` command. This command first checks **whether a database with the corresponding name exists**. If it does, the database is deleted; if not, the command simply does nothing, avoiding an error message. For our example above, the command would be:

```sql
DROP DATABASE IF EXISTS Customers;
```

## Delete multiple databases

To delete several databases at the same time, simply list them with commas. SQL DROP DATABASE could then look like this:

```sql
DROP DATABASE Customers, Employees, Branches;
```

In this case, you would remove the Customers, Employees and Branches databases at the same time.

## Display existing databases

To check which databases are on your system, use the `SHOW DATABASE` command. This will list all databases. If the deletion was successful, the removed databases will no longer appear in the list. This command is an effective method for verifying that the SQL DROP DATABASE command was executed correctly. The syntax is as follows:

```sql
SHOW DATABASES;
```

## Similar commands to SQL DROP DATABASE

In many cases, you may not want to delete the entire database but only individual entries or tables. SQL offers several commands for this purpose. To remove an entire table, use `DROP TABLE`. If you want to keep the table but empty it completely, `TRUNCATE TABLE` is the right choice. You can also use the [SQL DELETE](https://www.ionos.com/digitalguide/server/configuration/sql-delete/) statement can also be used to empty a table entirely, and it allows for conditions so that only specific columns or entries are affected if needed.

Tip MSSQL, MySQL or MariaDB? With [SQL Server Hosting](https://www.ionos.com/cloud/sql-server-hosting "SQL Server Hosting from IONOS") from IONOS, you get to choose and benefit from strong performance, extensive security features and expert, personal advice.


This is a markdown version of: [https://www.ionos.com/digitalguide/server/configuration/sql-drop-database/](https://www.ionos.com/digitalguide/server/configuration/sql-drop-database/) for AI/LLM consumption.