Deletes a database.
When this statement executes in Oracle Rdb, SQL deletes all
the database root and storage area files associated with the
database.
If you specify a repository path name in the DROP DATABASE
statement or specify an alias for a database attached with the
PATHNAME argument, SQL also deletes the repository directory that
contains the database definitions.
CAUTION
Use the DROP DATABASE statement with care. You cannot use
the ROLLBACK statement to cancel a DROP DATABASE statement.
When you use this statement, SQL deletes the database root
and storage area files, which include all data and all
definitions.
1 – Environment
You can use the DROP DATABASE statement:
o In interactive SQL
o Embedded in host language programs to be precompiled
o As part of a procedure in an SQL module
o In dynamic SQL as a statement to be dynamically executed
2 – Format
DROP DATABASE --------------------------------------------------+
+-------------------------- <----------------------------------+
+-> ALIAS <alias> ---------------------------------------------+-->
+-> FILENAME 'db-attach-spec' ------+-+----------------------+-+
+-> PATHNAME <path-name> -----------+ +-> literal-user-auth -+
db-attach-spec =
--+----------------+-> <file-spec> --->
+-> <node-spec> -+
node-spec =
-+-> <nodename> -+-------------------+-+->
| +-> <access-string> + |
+------------------ :: <--------------+
access-string =
-+-> " <user-name> <password> " --+->
+-> " <VMS-proxy-user-name> " ---+
literal-user-auth =
---> USER '<username>' -+------------------------+-->
+-> USING '<password>' -+
3 – Arguments
3.1 – ALIAS alias
Specifies the alias for an attached database. The DROP DATABASE
statement deletes the database and all database root and storage
area files associated with the alias.
If the database was declared with the PATHNAME argument, the DROP
DATABASE statement also deletes the repository directory that
contains the database definitions.
3.2 – FILENAME
Specifies a quoted string containing full or partial information
needed to access a database. An attach specification contains the
file specification of the .rdb file.
The DROP DATABASE statement deletes the database and all
database system files associated with the database root file
specification. If you use a partial file specification, SQL uses
the standard defaults. The DROP DATABASE statement deletes only
the database files, whether or not there is also a repository
directory containing database definitions.
3.3 – literal-user-auth
Specifies the user name and password for access to databases,
particularly remote database.
This literal lets you explicitly provide user name and password
information in the DROP DATABASE statement.
3.4 – PATHNAME
Specifies a full or relative repository path name for the
repository directory where the database definitions are stored.
Use a path name instead of a file specification to delete the
repository database definitions from the repository along with
the database root and storage area files. See also the DROP
PATHNAME statement.
3.5 – USER username
Defines a character string literal that specifies the operating
system user name that the database system uses for privilege
checking.
3.6 – USING password
Defines a character string literal that specifies the user's
password for the user name specified in the USER clause.
4 – Examples
Example 1: Deleting files only
The following statement deletes the database system files for
the database associated with the database personnel.rdb. If this
database also had definitions stored in a repository directory,
this DROP DATABASE statement would not delete those definitions.
SQL> DROP DATABASE FILENAME personnel;
Example 2: Deleting files and repository definitions
To delete database files and repository definitions, you
must specify a repository path name in the DROP DATABASE
statement. This statement deletes the repository directory
CDD$TOP.ACCOUNTING.PERSONNEL in addition to all database root
and storage area files associated with it.
SQL> DROP DATABASE PATHNAME CDD$TOP.ACCOUNTING.PERSONNEL;