Grant permission to all objects of a schema to apps user(Oracle 10g)

Dear Fiiends,
I would like to grant permission on all objects of a particular schema to apps user(Oracle 10g).How do I do it?
(ex)grant all on <schemaname>.<objectname> to apps with grant option.
This is the permission i want to give but i can't do it for all objects one by one so how do i do it in a single command.
Regards,
Arun

You can't do it in a single command. You have to give object-by-object privileges (you could grant something like SELECT ANY TABLE, but that applies to every schema in the database and is generally a rather bad idea). You can, however, use a bit of dynamic SQL to do the job, i.e.
FOR x IN (SELECT * FROM user_tables)
LOOP
  EXECUTE IMMEDIATE 'GRANT ALL ON schema_name.' || x.table_name || ' TO apps WITH GRANT OPTION';
END LOOP;You can do the same with other object types, hit DBA_TABLES rather than USER_TABLES if you don't want to run this as the object owner, etc.
Justin

Similar Messages

  • Grant permission to all packages in another schema

    Is there a way I can grant access to all the packages in another user's schema?
    Please guide me.
    Thanks!

    The one way is to use cursor :
    BEGIN
      FOR Rec IN (SELECT object_name, object_type FROM all_objects WHERE owner='SOURCEUSER' AND object_type IN ('PACKAGE')) LOOP
          EXECUTE IMMEDIATE 'GRANT EXECUTE ON SOURCEUSER.'||Rec.object_name||' TO TARGETUSER';
        END IF;
      END LOOP;
    END;Edited by: Radrigez on 13.07.2011 21:38

  • Grant access to all object/tables in other schemas to a user

    Is there any and simple way to grant access to all object/tables in other schemas (more than one) to a scheme/user?
    Thanks.
    Tarman.

    HI.
    grant SELECT ANY TABLE,delete any table, insert any table to user; Giving this delete,insert ANY TABLE privilege to a user can be dangerous and the use can mislead it. Its better to create a dynamic script and then grant it.
    E.g Suppose you want to give select,inert,delete,update privileges to user A on user B's object.
    sql> spool grants.sql
    sql> select 'grant select,insert,update,delete on '||owner||'.'||table_name||' to A;' from dba_tables where owner='B';
    sql>@grants.sqlHTH
    Anand

  • Grant select on all table of a schema to role

    Hi , is it possible to grant select on all table on a schema to a role?

    To grant SELECT on all tables of the current schema to particular role or user:
    SELECT 'GRANT SELECT ON '||TABLE_NAME||' TO READ_ONLY_ROLE;' COMMAND
    FROM (
    SELECT TABLE_NAME
    FROM ALL_TABLES
    WHERE OWNER = (SELECT USER FROM DUAL)
    Then copy and execute the result commands, eg:
    GRANT SELECT ON DEPT TO READ_ONLY_ROLE;
    GRANT SELECT ON EMP TO READ_ONLY_ROLE;
    GRANT SELECT ON DEMO_USERS TO READ_ONLY_ROLE;
    GRANT SELECT ON DEMO_CUSTOMERS TO READ_ONLY_ROLE;
    GRANT SELECT ON DEMO_ORDERS TO READ_ONLY_ROLE;

  • Audit activity for all objects in a schema

    Hi,
    Is there a way to audit all DDL statements and certain DML statements (i.e. DELETE) for all objects in a particular schema? I've been going through the Oracle documentation, and there doesn't seem to be a straightforward way to do this. For example, I've figured out that I can audit all DELETEs (too broad) or DELETEs on a particular schema object (too narrow), but nothing in between.
    The "AUDIT...BY <USER>" statement looked promising, but it doesn't cover statements issued by other users with access to the schema.
    Any help greatly appreciated!

    Is there a way to audit all DDL statements and certain DML statements (i.e. DELETE) for all objects in a particular schema?You can audit all the DDLs you need and the DMLs you need.
    For example, I've figured out that I can audit all
    DELETEs (too broad) or DELETEs on a particular schema
    object (too narrow), but nothing in between.I think you need to explain more on what you need to do because your "but nothing in between" is not clear.
    Something in between ?
    SQL>AUDIT DELETE ON EMP;
    SQL>AUDIT DELETE ON EMP WHENEVER SUCCESSFUL;
    SQL>AUDIT DELETE ON EMP WHENEVER NOT SUCCESSFUL;
    SQL>AUDIT SELECT ON EMP;
    The "AUDIT...BY <USER>" statement looked promising, but it doesn't cover statements issued by other users with access to the schemaYou can audit BY ACCESS, BY PROXY, BY SESSION

  • Grant privileges to all objects

    Oracle 11.0.1.7.0:
    When I create new user I do something like:
    create user abc identified by abc
    grant create session, create table, create views, create snapshot to abc - separate grant for each object
    grant unlimited tablespace to abc;So when I do that sometimes I forget privileges for sequences. Is there a way to give privilege in one sql to the user to let that user create table, views, session, tablespace etc.
    Edited by: user628400 on Jun 9, 2009 5:35 PM

    Is there a list of things like create table, session etc. that I can look at to determine what options I have?select distinct privilege from role_sys_privs order by 1;
    will give you a list of privileges which can be granted to role.
    is there a way to grant privileges to all different types like create table, session etc in one statement without having to type each one of them separately like grant create session, grant table?As other replied, this can be achieved by creating a role like:
    SQL> create role newrole;
    Role created.
    SQL> grant create table,query rewrite to newrole;  -- Or any privilege by above command.
    Grant succeeded.
    SQL> grant newrole to <YourUserName>;  --
    Grant succeeded.HTH
    Girish Sharma

  • Search script generator for all objects and data (!) from a user/schema ?

    Is there a way to create a script which (when run) creates all the existing
    TABLES; INDEXES, KEYS and DATA for a specified user/schema ?
    This (PL-)SQL script should contain all INSERTS for the currently existing rows of
    all the TABLEs.
    When I use e.g. export to Dumpfile I have at first find all TABLEs and components
    which I want to dump. This is rather uncomfortable.
    I just want to specify the user name similar to
    createscript user=karl@XE outfile=D:\mydata\myscript.sql
    Is this somehow possible ?

    So that I understand your requirements exactly, are you asking for your script to ...
    1/ export from database A the entire schema of a specified user
    2/ drop all objects owned by that user in database B
    3/ import the objects from database A into database B
    If so, it sounds to me that a shell script that does a schema level export as Nicholas suggested, and then drops the user from database B using the cascade keyword (e.g. drop user username cascade), recreates the user and then imports the export file into B should do the trick.
    I don't think searching for individual tables and creating the statements to recreate them is the best idea.
    Hope that helps
    Graham

  • Granting select on all objects of apps in R12

    Hi All,
    How can I achieve like user xxx having read only access to apps user objects in EBS R12.
    Best Regards,

    Pls check this thread
    READ-ONLY APPS Schema in EBS.
    and you can also check this
    http://souravpupu.blogspot.com/2011/09/how-to-create-apps-read-only-user.html
    thanks

  • Grant select on all tables of a schema

    I need to grant select on all tables (over 200 tables) of a schema to other users. Are there any SQL syntax to do this?
    Thanks!

    Execute the following script, modify it for your environment:
    Script
    Accept from_owner char prompt 'Grant from user:'
    Accept to_user char prompt 'grant to user:'
    set head off;
    set lines 300;
    set pages 0;
    set termout off;
    set feedback off;
    set head off;
    set verify off;
    spool d:\temp\grant.sql
    select 'grant select on &from_owner..'||
      table_name||
      ' to &to_user;'
      from dba_tables
      where owner=upper('&&from_owner');
    spool off;
    set head on;
    set pages 24;
    set termout on;
    set feedback on;
    set head on;
    @d:\temp\grant.sqlExecution example:
    system@DBA> @d:\temp\grants.sql
    Grant from user:scott
    grant to user:ejemplo
    Grant succeeded.
    Grant succeeded.
    Grant succeeded.
    Grant succeeded.
    Grant succeeded.
    Grant succeeded.
    Grant succeeded.

  • I need OrderEntry schema SQL file for Oracle 10g Express

    It seems Oracle 10g Express does not come with oe schema.
    I do not want to download another Oracle.

    I think its doable:
    1) http://www.oracle.com/technology/obe/obe1013jdev/common/OBEConnection.htm
    Download the sample_schema_scripts9i10g.zip
    Since you have Oracle Express you should unzip it to :
    C:\oraclexe\app\oracle\product\10.2.0\demo
    Thereafter copy
    C:\oraclexe\app\oracle\product\10.2.0\demo\schema\order_entry
    to
    C:\oraclexe\app\oracle\product\10.2.0\server\demo\schema
    then :
    C:\oraclexe\app\oracle\product\10.2.0\demo\schema>path=c:\oraclexe\app\oracle\pr
    oduct\10.2.0\server\BIN
    C:\oraclexe\app\oracle\product\10.2.0\demo\schema>sqlplus system/manager
    then
    @mksample as described in http://www.oracle.com/technology/obe/obe1013jdev/common/OBEConnection.htm
    I agree with you that this was not straight forward since these scripts are pretty complex, but I did this now and I have at least the customer - orders relation up and running so I hope it helps.
    kind regards
    Terje

  • How to grant accountB view only permission to all objects owner by accountA

    Hello,
    I would like to accountB have view only access to AccountA's objects, tables, views, procedure names and code, functions name and code, etc.
    I do NOT want the accountB create any new object or execute any object belongs to accountA.
    How do I do that?
    Thanks.

    Tables and views are relatively easy, but you've got to do it on an object by object basis (thus it will need to be part of the promotion process whenever A creates a new object). You can write a bit of dynamic SQL to handle the grants for existing objects.
    CREATE ROLE a_read_only;
    BEGIN
      FOR t IN (SELECT * FROM dba_tables WHERE owner = 'A')
      LOOP
        EXECUTE IMMEDIATE 'GRANT SELECT ON a.' || t.table_name || ' TO a_read_only';
      END LOOP;
      FOR t IN (SELECT * FROM dba_views WHERE owner = 'A')
      LOOP
        EXECUTE IMMEDIATE 'GRANT SELECT ON a.' || t.view_name || ' TO a_read_only';
      END LOOP;
    END;
    GRANT a_read_only
       TO b;Granting access to code is a bit more complex (at least potentially). From a database perspective, you can grant A SELECT access on DBA_SOURCE. That will allow B to write queries against DBA_SOURCE to see code but it will apply to all code that anyone owns, not just A. And if B is using a tool to try to view the code, that tool will generally want to query ALL_SOURCE which only has data for the source of objects that B has the ability to execute. You could create a view that exposes just the rows from DBA_SOURCE that you want B to see but then no tool will ever be able to display the source.
    Justin

  • Downcasting In Object PL/SQL Does not Work in Oracle 10g 10.1.0.2

    create type one_t as object (
    x number, y date ) not final
    create type two_t under one_t()
    set serverout on
    declare
    super one_t;
    sub two_t := two_t(1, sysdate);
    begin
    super := one_t(1, sysdate);
    sub := new two_t(1, sysdate);
    dbms_output.put_line('sub ' || sub.x || ' ' || sub.y );
    select treat(super as two_t) into sub from dual;
    dbms_output.put_line('super ' || super.x || ' ' || super.y );
    if sub is null then
    dbms_output.put_line('stupid');
    end if;
    if sub is of (two_t) then
    dbms_output.put_line('stupid');
    end if;
    end;
    The Other Piece Does not Even Compile
    declare
    super one_t;
    sub two_t := two_t(1, sysdate);
    begin
    super := one_t(1, sysdate);
    sub := treat(super as two_t);
    dbms_output.put_line('sub ' || sub.x || ' ' || sub.y );
    select treat(super as two_t) into sub from dual;
    dbms_output.put_line('super ' || super.x || ' ' || super.y );
    if sub is null then
    dbms_output.put_line('stupid');
    end if;
    if sub is of (two_t) then
    dbms_output.put_line('stupid');
    end if;
    end;
    ORA-06502: PL/SQL: numeric or value error: cannot assign supertype instance to
    subtype
    ORA-06512: at line 6

    You need use correct type when you create object.
    Don't forget object in reality is a memory pointer,
    so what if you don't allocate correct memory in creation,
    you can't treat object as subtype.
    And meanwhile, it doesn't depend on Oracle version -
    your example doesn't work in 9.2.0.1 for example.
    SQL> declare
      2  super one_t;
      3  sub two_t := two_t(1, sysdate);
      4  begin
      5  super := two_t(1, sysdate);
      6  sub := treat(super as two_t);
      7  dbms_output.put_line('sub ' || sub.x || ' ' || sub.y );
      8  select treat(super as two_t) into sub from dual;
      9  dbms_output.put_line('super ' || super.x || ' ' || super.y );
    10  if sub is null then
    11  dbms_output.put_line('stupid');
    12  end if;
    13  if sub is of (two_t) then
    14  dbms_output.put_line('stupid');
    15  end if;
    16  end;
    17  /
    sub 1 08.06.05
    super 1 08.06.05
    stupid
    &nbsp
    PL/SQL procedure successfully completed.Rgds.

  • Downcasting in Object PL/SQL Does not Work in Oracle 10g Enterprise Edition

    create type one_t as object (
    x number, y date ) not final
    create type two_t under one_t()
    set serverout on
    declare
    super one_t;
    sub two_t := two_t(1, sysdate);
    begin
    super := one_t(1, sysdate);
    sub := new two_t(1, sysdate);
    dbms_output.put_line('sub ' || sub.x || ' ' || sub.y );
    select treat(super as two_t) into sub from dual;
    dbms_output.put_line('super ' || super.x || ' ' || super.y );
    if sub is null then
    dbms_output.put_line('stupid');
    end if;
    if sub is of (two_t) then
    dbms_output.put_line('stupid');
    end if;
    end;
    The Other Piece Does not Even Compile
    declare
    super one_t;
    sub two_t := two_t(1, sysdate);
    begin
    super := one_t(1, sysdate);
    sub := treat(super as two_t);
    dbms_output.put_line('sub ' || sub.x || ' ' || sub.y );
    select treat(super as two_t) into sub from dual;
    dbms_output.put_line('super ' || super.x || ' ' || super.y );
    if sub is null then
    dbms_output.put_line('stupid');
    end if;
    if sub is of (two_t) then
    dbms_output.put_line('stupid');
    end if;
    end;
    ORA-06502: PL/SQL: numeric or value error: cannot assign supertype instance to
    subtype
    ORA-06512: at line 6

    You need use correct type when you create object.
    Don't forget object in reality is a memory pointer,
    so what if you don't allocate correct memory in creation,
    you can't treat object as subtype.
    And meanwhile, it doesn't depend on Oracle version -
    your example doesn't work in 9.2.0.1 for example.
    SQL> declare
      2  super one_t;
      3  sub two_t := two_t(1, sysdate);
      4  begin
      5  super := two_t(1, sysdate);
      6  sub := treat(super as two_t);
      7  dbms_output.put_line('sub ' || sub.x || ' ' || sub.y );
      8  select treat(super as two_t) into sub from dual;
      9  dbms_output.put_line('super ' || super.x || ' ' || super.y );
    10  if sub is null then
    11  dbms_output.put_line('stupid');
    12  end if;
    13  if sub is of (two_t) then
    14  dbms_output.put_line('stupid');
    15  end if;
    16  end;
    17  /
    sub 1 08.06.05
    super 1 08.06.05
    stupid
    &nbsp
    PL/SQL procedure successfully completed.Rgds.

  • GRANT SELECT ON ALL TABLES

    Is there a direct SQL to grant select on all tables in the schema for a user? Or do we need to write a PLSQL for this?
    Also, if a new table T1 is created or existing table T2 is dropped and recreated after granting the select all privilege, will the user have access to T1 and T2?
    thanks

    Is there a direct SQL to grant select on all tables
    in the schema for a user? Or do we need to write a
    PLSQL for this?There is no privilege that would give user A access to all the tables in schema B. You would need to grant access to each object, which can certainly be done via dynamic SQL in PL/SQL.
    There is a privilege SELECT ANY TABLE which allows the user to query any table in the system, but this is generally very dangerous and probably not something you would want to give a normal user.
    Also, if a new table T1 is created or existing table
    T2 is dropped and recreated after granting the select
    all privilege, will the user have access to T1 and
    T2?Unless you grant SELECT ANY TABLE, you would need to explicitly grant A access to any new tables created in schema B (or to tables after they are dropped and re-created). Potentially, you could create a DDL trigger that submitted a job that would, in turn, make the grant whenever a new table was created in schema B.
    Justin

  • How to give select prvileges on objects in ONE schema only.

    hi.. i wanna to do gve a select on tables only privilege to all objects in one schema only,
    is there any single command that enable me to do so ?
    or do i have to allocate priviledge to each and every schema objects available ?

    I think there is no command that will give permission on all the objects in one go.
    but u can do it in some tricky way.
    some thing like this
    spool permission.sql
    SELECT 'grant select on '||TABLE_NAME|| ' to abc; ' FROM USER_TABLES
    spool off
    change the abc user with the real schema name
    then run the permission.sql file connected with the user containing the tables.
    first try this on some test db and check if it works
    regards
    Ansh

Maybe you are looking for