This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-24. For the latest, interactive version please visit https://mariadb.com/kb/.

DROP DATABASE

Sintassi

DROP {DATABASE | SCHEMA} [IF EXISTS] nome_db

Spiegazione

DROP DATABASE elimina il database specificato e tutte le tabelle in esso contenute. Occorre prestare molta attenzione! Per usare DROP DATABASE, occorre disporre del privilegio DROP sul database interessato. DROP SCHEMA è sinonimo di DROP DATABASE.

Importante: Quando un database viene eliminato, i permessi degli utenti relativi a quel database non vengono cancellati. Si veda GRANT.

IF EXISTS serve ad evitare che venga generato un errore se il database non esiste.

Esempio

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
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.