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

Example 2

key_db is the database where the encryption key resides and col_db is the database containing the encrypted columns. 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 

Usage


Encrypted columns and drop database

To prevent accidental loss of keys, drop database fails if the database contains keys currently used to encrypt columns in other databases. To drop a database:


Restrictions

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

The permission checks for drop database differ based on your granular permissions settings.

Granular permissions enabled

With granular permissions enabled, you must be the database owner or have the own database privilege on the database. To drop sybsecurity, you must be the database owner or have the manage auditing privilege.

Granular permissions disabled

With granular permissions disabled, you must be the database owner, a user with sa_role, or for sybsecurity, a user with sso_role.

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 is in effect

See also

Commands alter database, create database, dbcc, use

Procedures sp_changedbowner, sp_helpdb, sp_renamedb, sp_spaceused