DROP Statement

Removes objects from the database.

Quick Links:

Go to Parameters

Go to Examples

Go to Usage

Go to Standards

Go to Permissions

Syntax

DROPDBSPACE dbspace-name
   | { DATATYPE [ IF EXISTS ]
   | DOMAIN } datatype-name
   | EVENT [ IF EXISTS ]  event-name
   | INDEX [ IF EXISTS ]  [ [ owner].table-name.]index-name
   | MESSAGE message-number
   | TABLE [ IF EXISTS ]  [ owner.]table-name
   | VIEW [ IF EXISTS ]  [ owner.]view-name
   | MATERIALIZED VIEW [ IF EXISTS ]  [ owner.]view-name
   | PROCEDURE [ IF EXISTS ]  [ owner.]procedure-name
   | FUNCTION [ IF EXISTS ]  [ owner.]function-name }

Parameters

(back to top)

Examples

(back to top)

Usage

(back to top)

DROP removes the definition of the indicated database structure. If the structure is a dbspace, then all tables with any data in that dbspace must be dropped or relocated prior to dropping the dbspace; other structures are automatically relocated. If the structure is a table, all data in the table is automatically deleted as part of the dropping process. Also, all indexes and keys for the table are dropped by DROP TABLE.

DROP DBSPACE is prevented whenever the statement affects a table that is currently being used by another connection. DROP PROCEDURE is prevented when the procedure is in use by another connection.

Side Effects
  • Automatic commit. Clears the Data window in dbisql. DROP TABLE and DROP INDEX close all cursors for the current connection.
  • Local temporary tables are an exception; no commit is performed when one is dropped.

Standards

(back to top)

  • SQL—ISO/ANSI SQL compliant.
  • SAP Sybase Database product—Supported by Adaptive Server.

Permissions

(back to top)

DBSPACE clause – Requires the DROP ANY OBJECT system privilege and user must be the only connection to the database.

DOMAIN clause – Requires one of:
  • DROP DATATYPE system privilege.
  • DROP ANY OBJECT system privilege.
  • You own the object.
FUNCTION clause – Requires one of:
  • DROP ANY PROCEDURE system privilege.
  • DROP ANY OBJECT system privilege.
  • You own the function.
INDEX clause – Requires one of:
  • DROP ANY INDEX system privilege.
  • DROP ANY OBJECT system privilege.
  • REFERENCES privilege on the underlying table being indexed.
  • You own the underlying table being indexed.
DBA or users with the appropriate privilege can drop an index on tables that are owned other users without using a fully-qualified name. All other users must provide a fully-qualified index name to drop an index on a base table owned by the DBA.
MATERIALIZED VIEW clause – Requires one of:
  • DROP ANY MATERIALIZED VIEW system privilege.
  • DROP ANY OBJECT system privilege.
  • You own the materialized view.
PROCEDURE clause – Requires one of:
  • DROP ANY PROCEDURE system privilege.
  • DROP ANY OBJECT system privilege.
  • You own the procedure.
TABLES clause – Requires one of:
  • DROP ANY TABLE system privilege.
  • DROP ANY OBJECT system privilege.
  • You own the table.
Global temporary tables cannot be dropped unless all users that have referenced the temporary table have disconnected.
VIEW clause – Requires one of:
  • DROP ANY VIEW system privilege.
  • DROP ANY OBJECT system privilege.
  • You own the view.
All other clauses – Requires one of:
  • DROP ANY OBJECT system privilege.
  • You own the object.