DROP DATABASE is a Data Definition Language (DDL) command that deletes a database, including every table, view, function, and stored procedure it contains. Once executed, the operation is irreversible; the data cannot be recovered unless backups exist. Most engines require that no active connections use the target database. Many dialects offer an IF EXISTS clause to avoid errors when the database is missing. Some systems also support additional options such as FORCE or WITH (ROLLBACK AFTER) to terminate connections or set timeouts. Because DROP DATABASE affects the entire schema, it should be executed only by privileged users in maintenance windows or automated teardown scripts.
IF EXISTS
(keyword) - Suppresses an error if the database does not existdatabase_name
(identifier) - The name of the database to dropCREATE DATABASE, ALTER DATABASE, DROP SCHEMA, DROP TABLE, BACKUP DATABASE
MySQL 3.22; later adopted by PostgreSQL 7.3 and SQL Server 2000
Use the IF EXISTS clause: `DROP DATABASE IF EXISTS db_name;` This prevents an error if the database is already gone.
Active connections are still using the target database. Terminate sessions or use options like `WITH (FORCE)` in PostgreSQL.
No. It deletes the live database files but does not delete external backups or snapshots.
Only users with superuser or DROP privilege on the database (often DBAs or admin roles) can execute this command safely.