Saturday, 30 September 2017

SQL DROP Statement


In Oracle DROP TABLE statement is use to remove the table from Oracle data base.
For DROP TABLE you should have DROP ANY TABLE system privilege.
DROP TABLE will drop the  associated table indexes  and triggers  and all dependent objects became INVALID.
All synonyms for a dropped table remain, but return an error when used.

Syntax:


DROP TABLE [schema].table_name [ CASCADE CONSTRAINTS(optional) ] [ PURGE (optional) ];
CASCADE CONSTRAINTS
Specify CASCADE CONSTRAINTS to drop all referential integrity constraints that refer to primary and unique keys in the dropped table. If you omit this clause, and such referential integrity constraints exist, then the database returns an error and does not drop the table.

PURGE

Specify PURGE if you want to drop the table and release the space associated with it in a single step. If you specify PURGE. We can not recover the table if we use the PURGE.

Example:



DROP TABLE STUDENT PURGE;

DROP TABLE example will remove STUDENT table from the data base and PURGE will release the space .




No comments:

Post a Comment