{"id":216,"date":"2018-02-03T16:10:59","date_gmt":"2018-02-03T16:10:59","guid":{"rendered":"http:\/\/eipsoftware.com\/musings\/?p=216"},"modified":"2018-02-19T16:12:09","modified_gmt":"2018-02-19T16:12:09","slug":"dropping-tables-in-oracle-pl-sql","status":"publish","type":"post","link":"https:\/\/eipsoftware.com\/musings\/dropping-tables-in-oracle-pl-sql\/","title":{"rendered":"Dropping Tables in Oracle PL\/SQL"},"content":{"rendered":"<h4>Dropping Tables<\/h4>\n<p>Below are some examples of how to create tables in Oracle 12. PL\/SQL, for the most part PL\/SQL follows standard SQL conventions.<\/p>\n<p><!--more--><\/p>\n<h5>Drop a Table<\/h5>\n<p>Normal way to drop a table.<\/p>\n<pre class=\"lang:plsql decode:true\">DROP TABLE EventRequest;<\/pre>\n<p>Nothing too fancy here, just drop the table.<\/p>\n<h5>Check before Dropping<\/h5>\n<p>While if you issue the DROP TABLE command and the table doesn&#8217;t exist, you will get an error message, however it isn&#8217;t too severe and can be ignored. Although in completeness I will show how to suppress or receive error messages when dropping a table.<\/p>\n<pre class=\"lang:plsql decode:true\">BEGIN\r\n    EXECUTE IMMEDIATE 'DROP TABLE EventRequest';\r\n    -- Other option is to use PURGE option\r\n    -- EXECUTE IMMEDIATE 'DROP TABLE EventRequest PURGE';\r\n    WHEN OTHERS\r\n    THEN\r\n        -- show the error message\r\n        DBMS_OUTPUT.put_line(SQLERRM);\r\n        -- suppress the error message\r\n        -- NULL\r\nEND;<\/pre>\n<p>In the above example there are a couple of options that you can use. Remove the comment indicator &#8220;&#8211;&#8221; from the beginning of the line, and add the comment indicator, &#8220;&#8211;&#8221; to the other line.<\/p>\n<p>The first one is if you want to immediately PURGE the table, and not send it to the recycle bin, you can use the PURGE option at the end of the DROP TABLE statement.<\/p>\n<p>The next option would be to show or suppress the error messages.\u00a0 You can either send the error message about the table not existing when trying to drop the table to NULL; and therefore never see the error message.\u00a0 Or you may want to see error messages related to trying to drop the table.<\/p>\n<p>I hope you found the above informative, let me know in the comments below.<\/p>\n<p><a href=\"mailto:michael.data@eipsoftware.com\">\u2014 michael.data@eipsoftware.com<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dropping Tables Below are some examples of how to create tables in Oracle 12. PL\/SQL, for the most part PL\/SQL follows standard SQL conventions.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[4,44,6],"tags":[14,30,48,49],"series":[],"class_list":["post-216","post","type-post","status-publish","format-standard","hentry","category-code","category-oracle-pl-sql","category-sql","tag-sql","tag-code","tag-pl-sql","tag-oracle"],"_links":{"self":[{"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/posts\/216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/comments?post=216"}],"version-history":[{"count":1,"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/posts\/216\/revisions"}],"predecessor-version":[{"id":217,"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/posts\/216\/revisions\/217"}],"wp:attachment":[{"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/media?parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/categories?post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/tags?post=216"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/eipsoftware.com\/musings\/wp-json\/wp\/v2\/series?post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}