DROP Statement
The DROP
statement is used to delete or remove database objects, such as tables, indexes, views, and other structures.
Once an object is dropped, it is permanently removed from the database, including all data and related properties.
The DROP
statement deletes database objects and frees up associated storage. It is typically used when:
- An object is no longer needed.
- Redesign requires replacing a table or view.
- Data cleanup requires removal of unused structures.
The DROP
statement is irreversible, means that once an object is dropped,
all data and settings for that object are lost permanently unless a backup is available.
Syntax -
DROP TABLE database_object;
- database_object: The name of the database object you wish to delete from the database.
Examples - DROP TABLE
DROP TABLE EMPLOYEE;
This command removes the EMPLOYEE
table from the database, including all data and definitions associated with it.
After this command, the table will no longer exist in DB2.
Using DROP Statements in a COBOL Program
We can't able to use the DROP
statement in COBOL-DB2 program as it is a DDL statement.
Only administrators and other users who has ADIM authority can use the DROP statement in DB2 tools (SPUFI or QMF).
DROP can be used on the below list of objects -
DROP ALIAS DROP DATABASE DROP FUNCTION DROP INDEX DROP PACKAGE DROP PROCEDURE DROP ROLE DROP SEQUENCE DROP STOGROUP DROP SYNONYM DROP TABLE DROP TABLESPACE DROP TRIGGER DROP TYPE DROP VIEW