Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » SQL statements » Alphabetical list of SQL statements

DROP DATABASE statement

Deletes all database files associated with a database.

Syntax
DROP DATABASE database-name [ KEY key ]
Remarks

The DROP DATABASE statement physically deletes all associated database files from disk. If the database file does not exist, or is not in a suitable condition for the database to be started, an error is generated.

DROP DATABASE cannot be used in stored procedures, triggers, events, or batches.

The database to be dropped must not be running when the DROP DATABASE statement is used. You cannot be connected to the database you are dropping. You must be connected to a different database. For example, connect to the utility database.

You must specify a key to drop a strongly encrypted database. The key can be either a string (constant literal) or a variable reference.

Privileges

Your ability to execute this statement depends on the setting for the -gu database option, and whether you have the SERVER OPERATOR system privilege.

Side effects

In addition to deleting the database files from disk, any associated transaction log file or transaction log mirror file is deleted.

Standards
  • ANSI/ISO SQL Standard

    Not in the standard.

Example

Execute the following statement to drop the database temp.db:

DROP DATABASE 'c:\temp\temp.db';
Execute the following statement to drop a database based on the constant literal, mykey:
DROP DATABASE 'temp.db' KEY 'mykey';
Execute the following statement to drop a database based on the variable reference, mykeyvar:
DROP DATABASE 'temp.db' KEY mykeyvar;