Skip to content


How to drop everything on a oracle schema

Posted in Database, Technology.

BEGIN
FOR cur_rec IN (SELECT table_name, constraint_name
FROM user_constraints
WHERE constraint_type = ‘R’) LOOP
EXECUTE IMMEDIATE ‘ALTER TABLE ‘ || cur_rec.table_name || ‘ DROP CONSTRAINT ‘ || cur_rec.constraint_name;
END LOOP;
FOR cur_rec IN (SELECT object_name, object_type
FROM user_objects) LOOP
BEGIN
EXECUTE IMMEDIATE ‘DROP ‘ || cur_rec.object_type || ‘ ‘ || cur_rec.object_name;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
execute immediate ‘purge recyclebin’;
END;
/

Note from Author :
I maintain my website, write articles and reply comments because of my interest/hobby to share information and knowledge.

If you liked the post, Please
Follow me on twitter: http://twitter.com/pankajbatracom
Join My facebook page: http://www.facebook.com/pankajbatra.blog
Join me on LinkedIn: http://www.linkedin.com/in/batrapankaj
Or subscribe to updates by Email by clicking here

To subscribe for updates, Enter your email address:

Related posts:

  1. How to schedule jobs in Oracle
  2. Substitute of LIMIT clause (as used in MySQL) in O…
  3. Selecting random rows from an oracle table
  4. How to send email from oracle stored procedure
  5. Facebook Email in response to Google Gmail Buzz


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Sanjay says

    thanks i almost tried this but then used squirrel and graphically deleted all tables (cascade constraints)







Some HTML is OK

or, reply to this post via trackback.