{"id":1516,"date":"2015-04-27T05:40:06","date_gmt":"2015-04-27T10:40:06","guid":{"rendered":"https:\/\/bijoos.com\/oraclenotes\/?p=1516"},"modified":"2026-02-07T14:58:53","modified_gmt":"2026-02-07T20:58:53","slug":"preventing-create-only-for-a-user","status":"publish","type":"post","link":"https:\/\/bijoos.com\/oraclenotes\/2015\/1516\/","title":{"rendered":"Preventing CREATE (only) for a User"},"content":{"rendered":"<p>The PL\/SQL reference guide has a short section and example for the <a href=\"http:\/\/docs.oracle.com\/cd\/E11882_01\/appdev.112\/e25519\/triggers.htm#LNPLS1967\" target=\"_blank\">INSTEAD OF CREATE ON SCHEMA<\/a>\u00a0trigger.\u00a0Since the description was so little and could not find much detail on the internet, tried some examples as below. This feature is good to prevent any CREATE operation for an user, giving him\/her privilege to alter or drop existing\u00a0object.<\/p>\n<p>The code below shows a simple trigger that raises an error when\u00a0any\u00a0CREATE statement is used by the user.<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">SQL&gt; show user\nUser is BTHOMAS\n\nSQL&gt; create or replace trigger prevent_new_objects\n  2   instead of create on schema\n  3   begin\n  4    raise_application_error(-20001, 'No new objects allowed in schema');\n  5   end;\nSQL&gt; \/\n\nTrigger created.\n\nSQL&gt; create table x1 (n1 number);\ncreate table x1 (n1 number)\n*\nERROR at line 1:\nORA-00604: error occurred at recursive SQL level 1\nORA-20001: No new objects allowed in schema\nORA-06512: at line 2\n\nSQL&gt;<\/pre>\n<p>If I connect as a different user, I can create table under BTHOMAS.<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">SQL&gt; connect system\/*\nConnected.\nSQL&gt; create table bthomas.x1 (n1 number);\n\nTable created.\n\nSQL&gt;<\/pre>\n<p>The restriction is honored even if I use EXECUTE IMMEDIATE to create the object from a PL\/SQL unit.<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">SQL&gt; begin\n  2  execute immediate 'create table x1 (n1 number)';\n  3  end;\n  4  \/\nbegin\n*\nERROR at line 1:\nORA-20001: No new objects allowed in schema\nORA-06512: at line 2\nORA-06512: at line 2\n\nSQL&gt;<\/pre>\n<p>Things are not different even if I create the trigger under another user (you cannot create this type of trigger under SYS user!). \u00a0In the code below, SYSTEM user creates the trigger owned by BTHOMAS, but still SYSTEM user cannot create any object. BTHOMAS user is unaffected.<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">SQL&gt; connect system\/*\nConnected.\nSQL&gt; create or replace trigger bthomas.prevent_new_objects\n  2   instead of create on schema\n  3   begin\n  4    raise_application_error(-20001, 'No new objects allowed in schema');\n  5*  end;\nSQL&gt; \/\n\nTrigger created.\n\nSQL&gt; create table x1 (x number);\ncreate table x1 (x number)\n*\nERROR at line 1:\nORA-00604: error occurred at recursive SQL level 1\nORA-20001: No new objects allowed in schema\nORA-06512: at line 2\n\n\nSQL&gt; create table bthomas.x1 (n number);\ncreate table bthomas.x1 (n number)\n*\nERROR at line 1:\nORA-00604: error occurred at recursive SQL level 1\nORA-20001: No new objects allowed in schema\nORA-06512: at line 2\n\nSQL&gt; show user\nUSER is \"SYSTEM\"\nSQL&gt; connect bthomas\/*\nConnected.\nSQL&gt; create table bthomas.x1 (n number);\n\nTable created.\n\nSQL&gt;\n<\/pre>\n<p>Querying DBA_TRIGGERS will clarify this&#8230;<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">SQL&gt; select OWNER, TRIGGER_NAME, TRIGGER_TYPE, TRIGGERING_EVENT,\n  2  TABLE_OWNER, BASE_OBJECT_TYPE\n  3  from dba_triggers\n  4  where trigger_name = 'PREVENT_NEW_OBJECTS';\n\nOWNER                          TRIGGER_NAME                   TRIGGER_TYPE\n------------------------------ ------------------------------ ----------------\nTRIGGERING_EVENT\n--------------------------------------------------------------------------------\nTABLE_OWNER                    BASE_OBJECT_TYPE\n------------------------------ ----------------\nBTHOMAS                        PREVENT_NEW_OBJECTS            UNDEFINED\nCREATE\nSYSTEM                         SCHEMA\n\n\nSQL&gt;<\/pre>\n<p>The user BTHOMAS has CREATE TABLE privilege, thus he gets drop table and alter table privileges which are unaffected by this trigger.<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">SQL&gt; Show USER\nUser is SYSTEM\nSQL&gt; create table d2 (n number);\ncreate table d2 (n number)\n*\nERROR at line 1:\nORA-00604: error occurred at recursive SQL level 1\nORA-20001: No new objects allowed in schema\nORA-06512: at line 2\n\nSQL&gt; drop table d1;\n\nTable dropped.\n\nSQL&gt;<\/pre>\n<p>Finally example below shows, any CREATE statement is affected, not just CREATE TABLE.<\/p>\n<pre class=\"lang:default highlight:0 decode:true \">SQL&gt; create synonym x for y;\ncreate synonym x for y\n*\nERROR at line 1:\nORA-00604: error occurred at recursive SQL level 1\nORA-20001: No new objects allowed in schema\nORA-06512: at line 2\n\n\nSQL&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The PL\/SQL reference guide has a short section and example for the INSTEAD OF CREATE ON SCHEMA\u00a0trigger.\u00a0Since the description was so little and could not find much detail on the internet, tried some examples as below. This feature is good to prevent any CREATE operation for an user, giving him\/her privilege to alter or drop &#8230; <a title=\"Preventing CREATE (only) for a User\" class=\"read-more\" href=\"https:\/\/bijoos.com\/oraclenotes\/2015\/1516\/\" aria-label=\"Read more about Preventing CREATE (only) for a User\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[133,22],"tags":[63],"class_list":["post-1516","post","type-post","status-publish","format-standard","hentry","category-oracledb","category-scripts-tools","tag-security"],"acf":[],"jetpack-related-posts":[{"id":21,"url":"https:\/\/bijoos.com\/oraclenotes\/2011\/21\/","url_meta":{"origin":1516,"position":0},"title":"Read Only Tables [Orig Published Apr 2000]","author":"Biju","date":"September 26, 2011","format":false,"excerpt":"In Oracle (all versions including 10g) you can make a tablespace read only, but not a single table. To make a table read only, you need to have that table in its own tablespace. If the tablespace has many tables, then you can either make all the tables read only\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":352,"url":"https:\/\/bijoos.com\/oraclenotes\/2014\/352\/","url_meta":{"origin":1516,"position":1},"title":"Two Cool Utilities in DBMS_UTILITY","author":"Biju","date":"May 18, 2014","format":false,"excerpt":"Oracle Database DBMS_UTILITY package has several useful subprograms. GET_DEPENDENCY shows the objects depended on the object. Here is an example (the procedure uses DBMS_OUTPUT to show the result, hence SET SERVEROUTPUT is required in SQL*Plus): SQL> set serveroutput on SQL> exec dbms_utility.get_dependency('VIEW','HR','EMP_DETAILS_VIEW'); - DEPENDENCIES ON HR.EMP_DETAILS_VIEW ------------------------------------------------------------------ *VIEW HR.EMP_DETAILS_VIEW() PL\/SQL\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1519,"url":"https:\/\/bijoos.com\/oraclenotes\/2015\/1519\/","url_meta":{"origin":1516,"position":2},"title":"Oracle Tidbits &#8211; April 2015","author":"Biju","date":"May 1, 2015","format":false,"excerpt":"\u201cOracle *daily* TidBits\u201d (#oratidbit) published at\u00a0https:\/\/www.facebook.com\/oraclenotes\u00a0on weekdays\u00a0in April\u00a02015. You will also see these tidbits, one tidbit at a time, for each page refresh on the right side of this blog as well\u2026 Hope you find these helpful to learn something new or to remind you of its existence and use\u2026\u2026","rel":"","context":"In &quot;TidBits &amp; Quick Tips&quot;","block_context":{"text":"TidBits &amp; Quick Tips","link":"https:\/\/bijoos.com\/oraclenotes\/category\/tidbits\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2197,"url":"https:\/\/bijoos.com\/oraclenotes\/2018\/2197\/","url_meta":{"origin":1516,"position":3},"title":"Oracle Tidbits &#8211; June 2018 #oratidbit","author":"biju.thomas","date":"July 1, 2018","format":false,"excerpt":"\u201cOracle *daily* TidBits\u201d (#oratidbit) published on\u00a0\u00a0Facebook,\u00a0Twitter,\u00a0and\u00a0Google+\u00a0during weekdays\u00a0in June 2018. Hope you find these helpful to learn something new or to remind you of its existence and use. #oratidbit #db18c A shared single client access name (Shared SCAN) enables the sharing of one set of SCAN virtual IPs (VIPs) and Listeners\u2026","rel":"","context":"In &quot;TidBits &amp; Quick Tips&quot;","block_context":{"text":"TidBits &amp; Quick Tips","link":"https:\/\/bijoos.com\/oraclenotes\/category\/tidbits\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bijoos.com\/oraclenotes\/wp-content\/uploads\/2018\/04\/oratidbit.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1588,"url":"https:\/\/bijoos.com\/oraclenotes\/2015\/1588\/","url_meta":{"origin":1516,"position":4},"title":"OCA12c \u2013 1Z0-061 \u2013 Additional Reading 07","author":"Biju","date":"September 5, 2015","format":false,"excerpt":"[Additional] Reading material for 1z0-061 Oracle Database 12c SQL Fundamentals test. Chapter 7: Creating Tables and Constraints\u00a0explains how to create and manage tables and constraints. It also discusses the various data types available in Oracle Database 12c to store data. 10 Introduction to Data Definition Language 10.1 Categorize the main\u2026","rel":"","context":"In &quot;Certification &amp; Learning&quot;","block_context":{"text":"Certification &amp; Learning","link":"https:\/\/bijoos.com\/oraclenotes\/category\/certification-learning\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":421,"url":"https:\/\/bijoos.com\/oraclenotes\/2014\/421\/","url_meta":{"origin":1516,"position":5},"title":"DBA_TAB_COLUMNS vs DBA_TAB_COLS","author":"Biju","date":"June 18, 2014","format":false,"excerpt":"Not sure how many DBAs have noticed the difference between DBA_TAB_COLUMNS view and DBA_TAB_COLS view. Both views look pretty identical, if you are not paying too much attention. According to Oracle documentation, DBA_TAB_COLS describes the columns of all tables, views, and clusters in the database. This view differs from \"DBA_TAB_COLUMNS\"\u2026","rel":"","context":"In &quot;Oracle Database&quot;","block_context":{"text":"Oracle Database","link":"https:\/\/bijoos.com\/oraclenotes\/category\/oracledb\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts\/1516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/comments?post=1516"}],"version-history":[{"count":1,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts\/1516\/revisions"}],"predecessor-version":[{"id":2954,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/posts\/1516\/revisions\/2954"}],"wp:attachment":[{"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/media?parent=1516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/categories?post=1516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bijoos.com\/oraclenotes\/wp-json\/wp\/v2\/tags?post=1516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}