Name
DROP DATABASE
Synopsis
DROP DATABASE
undoes all the work done by the CREATE
DATABASE
command. It drops all existing database
objects and releases the space used by them. With most vendors this
command cannot be executed while users (including the owner) are
active in the database.
Vendor |
Command |
---|---|
SQL Server |
Supported |
MySQL |
Supported |
Oracle |
Not supported |
PostgreSQL |
Supported |
SQL99 Syntax and Description
DROP DATABASE database_name
Like CREATE DATABASE
, DROP
DATABASE
is supported by ANSI SQL only as an extension and
not as a core command. SQL99 prefers commands relating to
SCHEMA
and DOMAIN
to cover
areas that roughly correspond to what most implementations would
consider “database” issues.
The system databases created by the database vendor should never be dropped. Dropping a database requires explicit permissions, unless performed by the database owner or the system administrator.
Microsoft SQL Server Syntax and Variations
DROP DATABASE database_name [,...n]
In SQL Server, multiple databases may be dropped in the same command
by adding a comma between each database name. A database may be
dropped only by a user in the master database, a user who has sys
admin privileges, or the database owner. The database must be
ONLINE
to be dropped.
MySQL and PostgreSQL Syntax and Variations
In MySQL and PostgreSQL, this command removes an entire database and all associated files. The DB sends a message indicating how many files were deleted. A database that is open and in use under the ...
Get SQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.