# DROP DATABASE

## Syntax

```sql
DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
```

## 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 [DROP privilege](https://mariadb.com/docs/server/reference/account-management-sql-statements/grant#table-privileges) 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](https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/grant).

#### 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 [SHOW WARNINGS](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/show/show-warnings).

### Atomic DDL

{% tabs %}
{% tab title="Current" %}
[MariaDB 10.6.1](https://app.gitbook.com/s/aEnK0ZXmUbJzqQrTjFyb/community-server/10.6/10.6.1) supports [Atomic DDL](https://mariadb.com/docs/server/reference/sql-statements/data-definition/atomic-ddl).`DROP DATABASE` is implemented as

```sql
LOOP OVER ALL tables
  DROP TABLE tbl
```

Each individual [DROP TABLE](https://mariadb.com/docs/server/server-usage/tables/drop-table) is atomic while `DROP DATABASE` as a whole is crash-safe.
{% endtab %}

{% tab title="< 10.6.1" %}
Atomic `DROP` is not available.
{% endtab %}
{% endtabs %}

## Examples

```sql
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
```

## See Also

* [CREATE DATABASE](https://mariadb.com/docs/server/reference/sql-statements/data-definition/create/create-database)
* [ALTER DATABASE](https://mariadb.com/docs/server/reference/sql-statements/data-definition/alter/alter-database)
* [SHOW DATABASES](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/show/show-databases)
* [Information Schema SCHEMATA Table](https://mariadb.com/docs/server/reference/system-tables/information-schema/information-schema-tables/information-schema-schemata-table)
* [SHOW CREATE DATABASE](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/show/show-create-database)

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
