drop database

Description

Removes one or more databases from Adaptive Server, including archive databases.

Syntax

drop database database_name [, database_name] ...

Parameters

database_name

is the name of a database to remove. Use sp_helpdb to get a list of databases.

Examples

Example 1

Removes the publishing database and all its contents:

drop database publishing

Usage


Encrypted columns and drop database

To prevent accidental loss of keys, Adaptive Server fails drop database if it contains keys currently used to encrypt columns in other databases. Before dropping the database containing the encryption keys you must first remove the encryption or drop the database containing the encrypted columns.

In the following example key_db is the database where the encryption key resides and col_db is the database containing the encrypted columns:

drop database key_db, col_db

Adaptive Server raises an error and fails to drop key_db. The drop of col_db succeeds. To drop both databases, drop col_db first:

drop database col_db, key_db 

Restrictions

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Only the Database Owner can execute drop database, except for the sybsecurity database, which can be dropped only by the System Security Officer.

Auditing

Values in event and extrainfo columns of sysaudits are:

Event

Audit option

Command or access audited

Information in extrainfo

26

drop

drop database

  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – NULL

  • Proxy information – Original login name, if set proxy in effect

See also

Commands alter database, create database, dbcc, use

Procedures sp_changedbowner, sp_helpdb, sp_renamedb, sp_spaceused