{"id":4803,"date":"2015-03-25T13:19:32","date_gmt":"2015-03-25T18:19:32","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=4803"},"modified":"2015-03-25T13:19:32","modified_gmt":"2015-03-25T18:19:32","slug":"drop-all-tables-in-a-schema","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2015\/03\/25\/drop-all-tables-in-a-schema\/","title":{"rendered":"Drop all tables in a schema"},"content":{"rendered":"<p>This assumes the tables have no integrity constraints related to a table in another schema.  This just loops until all tables are dropped.  If you are the nervous type, add an exception handler for the integrity constraint exception, and exit on all others.  The only one you see should be related to integrity constraints on tables that reference the one being dropped.<\/p>\n<pre>\r\nSQL> declare\r\n  2    l_count number := -1;\r\n  3  begin\r\n  4    while true loop\r\n  5      select count(*) into l_count from dba_tables where owner = 'ATG_CORE_QA3';\r\n  6      if l_count != 0 then\r\n  7        for r in (select * from dba_tables where owner = 'ATG_CORE_QA3') loop\r\n  8          begin\r\n  9            execute immediate 'drop table ' || r.owner || '.' || r.table_name || ' purge';\r\n 10          exception\r\n 11            when others then\r\n 12              null;\r\n 13          end;\r\n 14        end loop;\r\n 15      else\r\n 16        exit;\r\n 17      end if;\r\n 18    end loop;\r\n 19* end;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This assumes the tables have no integrity constraints related to a table in another schema. This just loops until all tables are dropped. If you are the nervous type, add an exception handler for the integrity constraint exception, and exit&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2015\/03\/25\/drop-all-tables-in-a-schema\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[22,29],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/4803"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=4803"}],"version-history":[{"count":2,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/4803\/revisions"}],"predecessor-version":[{"id":4807,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/4803\/revisions\/4807"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=4803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=4803"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=4803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}