Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

TRUNCATE TABLE giving error even with DROP ANY TABLE system privilege

sabyakgpDec 18 2020

Hi
I have a table called TEST1.T1:
create table test1.t1 (id int, constraint pk_id primary key(id));
and another called TEST1.T2:
create table test1.t2 (id int, constraint fk_id foreign key(id) references test1.t1(id) on delete cascade);
I have created a stored procedure in another schema TEST2.TPROC
create or replace procedure test2.tproc as
begin
execute immediate 'TRUNCATE TABLE TEST1.T1 CASCADE';
end tproc;
My user id is smitra and I have granted execute role to the user on this procedure:
grant execute on test2.tproc to smitra;
I also granted DROP ANY TABLE TEST2 user:
grant drop any table to test2;
When I execute this SP:
exec test2.tproc;
I get error:
BEGIN test2.tproc; END;
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "TEST2.TPROC", line 4
ORA-06512: at line 1
My question is when the TEST2 user, in which the procedure is defined, has the DROP ANY TABLE system privilege why it's throwing this error?
The only I was able to resolve the error is to change the DEFINER RIGHTS of the SP to INVOKER RIGHTS. Can somebody please explain why I am getting this error? I am using Oracle 12.1

Comments

807574
It's likely that you missed something in the creation of your user.

There are exactly two supported methods of creating a valid user:

commadmin

and Delegated Admin

Without you posting both ldap entries, how can I tell if you missed something?

I suggest using:

commadmin user create

don't forget to follow the documentation, to add the "service" to the domain first, and also to each user.
1 - 1

Post Details

Added on Dec 18 2020
5 comments
445 views