Drop all schema objects

Drop all schema objects

Be careful when you drop all schema objects safely in Oracle.

DECLARE
v_itemcount INTEGER;
BEGIN
SELECT Count(*)
INTO v_itemcount
FROM all_objects AO
WHERE AO.owner = USER
AND AO.object_type NOT IN ( ‘INDEX’ )
AND AO.object_name NOT LIKE ‘BIN$%’;

WHILE ( v_itemcount > 0 ) LOOP
FOR v_cmd IN (SELECT ‘drop ‘
|| AO.object_type
|| ‘ ‘
|| AO.object_name
|| Decode(AO.object_type, ‘TABLE’,
‘ CASCADE CONSTRAINTS’,
”) AS DROPCMD
FROM all_objects AO
WHERE AO.owner = USER
AND AO.object_type NOT IN ( ‘INDEX’ )
AND AO.object_name NOT LIKE ‘BIN$%’) LOOP
BEGIN
EXECUTE IMMEDIATE v_cmd.dropcmd;
EXCEPTION
WHEN OTHERS THEN
NULL; — ignore errors
END;
END LOOP;

SELECT Count(*)
INTO v_itemcount
FROM all_objects AO
WHERE AO.owner = USER
AND AO.object_type NOT IN ( ‘INDEX’ )
AND AO.object_name NOT LIKE ‘BIN$%’;
END LOOP;

EXECUTE IMMEDIATE ‘purge recyclebin’;
END;

NOTE: Be Careful Before Running It in the Production Environment

Read More Articles

How to Get Counts of All Tables in a Schema in PL/SQL?

How To Find Database Objects With Datafiles?

Find Total Undo Statistics

List All Undo Datafiles With Status And Size

To Check When a Table is Last Analysed

List All Datafile Of Undo Tablespace

Undo Space Used By All Transactions

List Of Long Running Queries

Undo Tablespace Utilization By All Sessions

To Check For Active Transactions

Datewise Occurrence Of ORA-1555

To Check Space Related Statistics Of Undo Tablespace

To Show Undo Retention Value

Extent Count And Total Blocks

To Show ACTIVE/EXPIRED/UNEXPIRED Extents of Undo Tablespace

To Check Retention Guarantee For Undo Tablespace

Inactive JDBC Sessions

Inactive Modules

Inactive Program

Toral Inactive Sessions More Than 1Hour

Inactive Programs With Disk Reads Prompt Inactive Sessions

Inactive Programs

Total Inactive Sessions

Total Count Of Sessions Ordered By Action

Total Count Of Sessions Ordered By Module

Total Sessions Count Ordered By Program

Count Of Active Sessions

Sessions Which Are In Inactive Status From More Than 1 HOUR

SQL Queries to Check Active or Inactive Sessions

Query To Find Database Redolog Temp And Control File Size

Query To Find Database Size

Query To Find Long Running SQL Statements

Query To Find Undo Tablespace Usage

Query To Check For Table Locks

Query To Find Active Sessions In Database

Query To Check Users Sessions CPU and IO Consumption

Query To Check Open Cursor By User

Query To Check Top 10 Database Load Queries

Query To Check List Of Locks In The Database

Query To Check Blocking Sessions Per User

Query To Check Size Of All Tablespaces

Query To Find The Details of The Accounting Flexfield Structure

Query To Find a Scheduled Job for a particular program

How to Find Scheduled Concurrent Program

How to Find The Request Group Associated with a Program

Query To Find Global Locks

Query To Check Web Sessions

Query To Verify Workflow IMAP Setting

Query To Find Complete Database Size

Query To Find Find EBS Profile Options For All Values

Query To Find Number Of Users Connected To EBS

Query To Find Who Is Connected When to Which Responsibilities

Query For Workflow Mailer Configurations

Query To Find All Responsibilities Assigned To a User

Query To Find All Users Assigned To Given Responsibility

Query To Find All Reports Registered Within Given Application

Query To Find Responsibility Name from a Concurrent Program

Query Count the number of reports registered In Each Module

Query To Find Scheduled Concurrent Request

Query To Find All Reports Status With User Name

Query To Count Pending Request

Query To find Concurrent Program Name, Phase Code And Status Code for a given Request ID

Query To Find a Concurrent Program Enabled with Trace

Query To Find Request Submitted By User

Query To Find Pending Request in Oracle Apps dba

Query To Find the Reports Finished With Error Code In Oracle Apps DBA

Terminating Report From Backend

Query To Check Total Scheduled Requests

Leave a Comment