Deletes the specified table definition. If you use the PATHNAME qualifier when you attach to the database, the DROP TABLE statement also deletes the table definition from the repository.
1 – Environment
You can use the DROP TABLE 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
(B)0[m[1;4mDROP[m[1m [1;4mTABLE[m[1m <table-name> qwqwqqqqqqqqqqqqqqqqwqwq> [m [1m [m [1mx tq> [1;4mCASCADE[m[1m [m [1mqqqu x [m [1m [m [1mx tq> [1;4mRESTRICT[m [1mqqqu x [m [1m [m [1mx mq> [1;4mIF[m[1m [1;4mEXISTS[m [1mqqqj x [m [1m [m [1mmqqqqqqqqqq<qqqqqqqqqj [m
3 – Arguments
3.1 – CASCADE
Specifies that you want SQL to delete all other definitions (constraints, indexes, modules, storage maps, triggers, and views) that refer to the named table and then delete that table definition. This is known as a cascading delete. For stored routines or triggers with a routine or language-semantic dependency, SQL also marks the affected routines and triggers as invalid.
3.2 – IF_EXISTS
Prevents SQL command language from displaying error messages if the referenced object does not exist in the database.
3.3 – RESTRICT
Specifies that you want SQL to delete only the named table definition. If constraints, modules, triggers, or views are defined that refer to the named table, SQL does not delete the table. If there are indexes or storage maps that refer to the named table, SQL deletes the table and storage map and does not issue an error.
3.4 – table-name
Specifies the name of the table definition you want to delete.
4 – Examples
Example 1: Deleting a table from an attached database SQL> ATTACH 'ALIAS PERS FILENAME personnel'; SQL> DROP TABLE PERS.DEGREES; SQL> COMMIT; Example 2: Deleting a table and definitions that reference it from the default database SQL> ATTACH 'FILENAME corporate_data'; SQL> DROP TABLE ADMINISTRATION.PERSONNEL.EMPLOYEES CASCADE; View ADMINISTRATION.PERSONNEL.REVIEW_DATE is also being dropped. View ADMINISTRATION.PERSONNEL.CURRENT_INFO is also being dropped. View ADMINISTRATION.PERSONNEL.CURRENT_SALARY is also being dropped. View ADMINISTRATION.PERSONNEL.CURRENT_JOB is also being dropped. Constraint ADMINISTRATION.RECRUITING.DEGREES_FOREIGN2 is also being dropped. Constraint ADMINISTRATION.PERSONNEL.EMPLOYEES_PRIMARY_EMPLOYEE_ID is also being dropped. Constraint ADMINISTRATION.PERSONNEL.EMP_SEX_VALUES is also being dropped. Constraint ADMINISTRATION.PERSONNEL.HOURLY_HISTORY_FOREIGN1 is also being dropped. Constraint ADMINISTRATION.PERSONNEL.JOB_HISTORY_FOREIGN1 is also being dropped. Constraint ADMINISTRATION.RECRUITING.RESUMES_FOREIGN2 is also being dropped. Constraint ADMINISTRATION.PERSONNEL.SALARY_HISTORY_FOREIGN1 is also being dropped. Constraint ADMINISTRATION.PERSONNEL.STATUS_CODE_VALUES is also being dropped. Index ADMINISTRATION.PERSONNEL.EMP_LAST_NAME is also being dropped. Index ADMINISTRATION.PERSONNEL.EMP_EMPLOYEE_ID is also being dropped. Trigger ADMINISTRATION.PERSONNEL.EMPLOYEE_ID_CASCADE_DELETE is also being dropped. Trigger ADMINISTRATION.PERSONNEL.STATUS_CODE_CASCADE_UPDATE is also being dropped.