Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: PRIVILEGE PROBLEMS USING EXECUTE IMMEDIATE!
fitzjarrell_at_cox.net wrote:
> stephen O'D wrote:
> > Michel Cadot wrote:
> >
> > > <Bullseye> a écrit dans le message de news: 50lmo1hnd1l7u7l1i0ghloljb22pfe1vm9_at_4ax.com...
> > > | Can anyone help me.
> > > |
> > > | I have a table in SCHEMA1:=
> > > |
> > > | create table TESTTAB (Dummy varchar2(10) );
> > > | grant alter,insert, update, delete, select ON TESTTAB to SCHEMA2
> > > |
> > > |
> > > | Within SCHEMA2 I can do:-
> > > | truncate table SCHEMA1.TESTTAB;
> > > |
> > > | But The following aborts with a Insufficient privileges:-
> > > |
> > > | create procedure DoIt IS
> > > | BEGIN
> > > | execute immediate 'TRUNCATE TABLE SCHEMA1.TESTTAB';
> > > | END;
> > > |
> > > | BEGIN
> > > | DoIt;
> > > | END;
> > > |
> > > |
> > > | There must be some additional privileges needed to use execute
> > > | immediate across Schema's. (these all work if all objects are in the
> > > | same Schema!
> > > |
> > > | TIA
> > > |
> > >
> > > 1/ I bet if you execute "set role none" then you can no more execute the truncate.
> > > 2/ If you can execute a truncate in another schema then you have "drop any table" privilege. Only DBA should have this high
> > > privilege (and even that i doubt) and never an application schema or user.
> > > 3/ If you really have the requirement to truncate schema1 table from schema2 then create a truncate_testtab procedure in schema1 and
> > > grant execute privilege on this procedure to schema2.
> > >
> > > Regards
> > > Michel Cadot
> >
> > If you can do the truncate table outside of PL/SQL (ie in SQLPLUS) then
> > you have probably got the privilege via a role in schema two.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>> > drop any table priv directly to the user it will work - but take the
> > If you grant the
>
>
> >
Well, I would say what is more unfortunate is that when someone is actually trying to be helpful you get flamed for it - especially when what I said was correct ...
The OP said he successfully executed
>Truncate table schema1.TestTab;
in SQLPLUS. The only grants given to schema2 are alter, insert, select, delete, update on testTab. All given directly to the user, and NONE of which will allow him to truncate a table in a different schema, but he was able to truncate it anyway, hence he had another privilege from somewhere.
The fact that he could not execute the same statement within PL/SQL means he had the privilege via role which was automatically disabled in PL/SQL. Michel correctly pointed out that if he executes 'set role none' then the command will no longer work in SQLPLUS - I simply clarified that this is because roles become disabled in PL/SQL - which was not mentioned, and the fact that the OP was asking this question implies he was unaware of this. I knew exactly what Michel ment, I just clarified that point.
Michel's third point was clearly the best solution to the problem, and I never questioned that ... but I felt it was useful to explain why set role none mysteriously made SQLPLUS behave the same as PL/SQL. Received on Wed Nov 30 2005 - 11:26:13 CST
![]() |
![]() |