ORA-01031 Insufficient privileges
FranklinFaces.com
FranklinFaces.com - Oracle & SQL Server Database Forums for all IT Professionals
 Home          Members     Calendar     Who's On

Welcome Guest ( Login | Register )
        



ORA-01031 Insufficient privileges Expand / Collapse
Message
Posted 7/9/2009 2:20:34 PM Post #138
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
I had a user that was getting the following ora error message while creating a table in another user's schema:

ORA-01031 Insufficient privileges

When i looked it up this is what oracle suggests:

01031, 00000, "insufficient privileges"
// *Cause: An attempt was made to change the current username or password
//         without the appropriate privilege. This error also occurs if
//         attempting to install a database without the necessary operating
//         system privileges.
//         When Trusted Oracle is configure in DBMS MAC, this error may occur
//         if the user was granted the necessary privilege at a higher label
//         than the current login.
// *Action: Ask the database administrator to perform the operation or grant
//          the required privileges.
//          For Trusted Oracle users getting this error although granted the
//          the appropriate privilege at a higher label, ask the database
//          administrator to regrant the privilege at the appropriate label.

However, this didn't solve my problem.   I gave the user the following privileges and still didn't work:

grant select any table to <user>;

grant drop any table to <user>;

grant create any table to <user>;

After doing this, still the user was having issues when logging in through his application via odbc connection.

After many tries, and research I granted all to the tables he was using :

grant all on <schema>.<table_name> to <user>;

and then also did the following:

grant references on <schema>.<table_name> to <user>;

That did the trick.  I hope this helps you out as well.

If that didn't work my last resort was to grant dba to the user.   Which I didn't want to do because that was just way too much privilege for him.

Thanks,

Posted 1/7/2011 1:53:44 PM Post #514
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
ORA-01031: insufficient privileges

*
ERROR at line 1:
ORA-01031: insufficient privileges

Execute Immediate within a stored procedure keeps giving insufficient priviliges error

So I have this procedure that i am trying to execute.  When i run it, it keeps giving me insufficient privileges error message:  ORA-01031 during the run.   Here is the procedure:


CREATE or replace PROCEDURE goldid.GID_REBUILD_UNUSABLE_IDXS
AS
    idx_name varchar2(100);
    idx_cnt integer;
begin
    select count(*) into idx_cnt from user_indexes where status = 'UNUSABLE';

    if idx_cnt > 0 then
         select index_name into idx_name from user_indexes where status = 'UNUSABLE' and rownum <= 1;
    else
        idx_name := null;
    end if;

    while idx_name is not null
    loop
        execute immediate 'alter index ' || idx_name || ' rebuild online parallel';
        select index_name into idx_name from user_indexes where status = 'UNUSABLE' and rownum <= 1;
    end loop;
end;
go

For some reason, I keep getting insufficient privileges error for the EXECUTE IMMEDIATE command. I found out that the insufficient privileges error usually means the oracle user account does not have privileges for the command used in the query that is passes, which in this case is alter index.

I granted the user alter any index directly to he user without going through the role, yet it still didn't work.

Posted 1/7/2011 1:57:26 PM Post #515
 

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being
I found the answer to my ora-01031 insufficient privileges error message that i'm getting while using execute immediate command:

Oracle needs to know explicitly somewhere in the procedure what kind of privileges to use. The way to let Oracle know that is to use AUTHID keyword in the CREATE OR REPLACE statement. If you want the same level of privileges as the creator of the procedure, you use AUTHID DEFINER. If you want Oracle to use the privileges of the user currently running the stored procedure, you want to use AUTHID CURRENT_USER.  Here is the updated procedure and it works great now.


CREATE or replace PROCEDURE goldid.GID_REBUILD_UNUSABLE_IDXS
AUTHID CURRENT_USER IS
begin
declare
    idx_name varchar2(100);
    idx_cnt integer;
begin
    select count(*) into idx_cnt from user_indexes where status = 'UNUSABLE';

    if idx_cnt > 0 then
         select index_name into idx_name from user_indexes where status = 'UNUSABLE' and rownum <= 1;
    else
        idx_name := null;
    end if;

    while idx_name is not null
    loop
        execute immediate 'alter index ' || idx_name || ' rebuild online parallel';
        select index_name into idx_name from user_indexes where status = 'UNUSABLE' and rownum <= 1;
    end loop;
end;
end;
/

Hope this helps you guys.

« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: silencer

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 5:35am

Powered By InstantForum.NET v4.1.4 © 2012
Execution: 0.073. 10 queries. Compression Disabled.
Contextual Links