O'Reilly logo

SQL in a Nutshell by Kevin Kline

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required