Subscribe to Posts by Email

Subscriber Count

    699

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

ORA-01031 insufficient privileges while creating database link

My friend has an issue yesterday which took sometime to figure out in important time during a release. Hooe this may help you too.

ORA-01031: insufficient privileges , while creating DB Link

SQL> select * from dba_sys_privs;

USERNAME PRIVILEGE ADM
------------------------------ ---------------------------------------- ---
TEST321 ALTER ANY PROCEDURE NO
TEST321 CREATE DATABASE LINK NO
TEST321 CREATE PUBLIC DATABASE LINK NO
TEST321 CREATE SESSION NO
TEST321 DELETE ANY TABLE NO
TEST321 EXECUTE ANY PROCEDURE NO
TEST321 INSERT ANY TABLE NO
TEST321 SELECT ANY TABLE NO
TEST321 UNLIMITED TABLESPACE NO
TEST321 UPDATE ANY TABLE NO

Even if I grant DBA priv I cant seem to create:

SQL> conn
Enter user-name: / as sysdba
Connected.
SQL> grant dba to TEST321;

Grant succeeded.

SQL> conn TEST321/bet123
Connected.

SQL> create database link test.world connect to PROD321 identified by ***** using 'test.world';
create database link TEST.world connect to PROD321 identified by *****
*
ERROR at line 1:
ORA-01031: insufficient privileges

What could be the reason?  uh! After verifying we found that ,

1) There is a logon trigger

SQL> select trigger_name,trigger_type,triggering_event  from dba_triggers where trigger_name='T_LOGON';

TRIGGER_NAME  TRIGGER_TYPE     TRIGGERING_EVENT
------------- ---------------- ----------------
T_LOGON       AFTER EVENT      LOGON

SQL>

2) Logon trigger written as, sets any user that logon this database will automatically set to another user TEST

Here is the piece of Trigger code

select text from dba_source where name='T_LOGON';

TRIGGER T_Logon

AFTER LOGON ON DATABASE
--
DECLARE
--
CURSOR c1 IS
.....

EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = TEST';

.....

This means, after immediately TEST321 logs on to the database , the session will be set as TEST

So , Well now the reason, the user TEST321 cannot create objects in TEST and thats why the reason ORA-01031, but question why still despite of granting DBA Role is failing,
again TEST does not have DBA Privs 🙂 we are granting to TEST321.

Now to resolve this, we have to again to set current_schema of our own

SQL> conn TEST321/bet123
Connected.

SQL> alter session set current_schema=TEST321;
Session altered.

SQL> create database link test.world connect to PROD321 identified by ***** using 'test.world';
Database link created.

Hope this helps.

2 comments to ORA-01031 insufficient privileges while creating database link

  • Ali

    A person help me that will be my pleasure ;
    I have create user in oracle 10G in sys as sysDBA. that is create succeed and connected as well but how to assign all privileges to my own created user. if some on to…..
    to reply with kindness .

    SQL> connect flshop/admin;
    Connected.
    SQL> create tablespace shoptb
    2 datafile
    3 ‘E:oracleproduct10.2.0flash_recovery_areashoptb_01.dbf’ SIZE 200M autoextend off,
    4 ‘E:oracleproduct10.2.0flash_recovery_areashoptb_02.dbf’ SIZE 200M autoextend off
    5 logging
    6 extent management local;
    create tablespace shoptb
    *
    ERROR at line 1:
    ORA-01031: insufficient privileges

    • Create tablespace required sysdba/dba privileges, First log with sysdba or dba and then create tablespace and then create user and then assign or provide quota on that tablespace to that user.

      Sorry for the delay in response.

      -Regards
      Geek DBA