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

Similar Messages

  • 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

  • Create package in another schema (10gR2)

    Hi there,
    I'm trying to create a package in another schema, but I am getting an error when I do this.
    My script is as follow:
    i log in as user rwn.
    create or replace package mkw.test
    as
    procedure t;
    end mkw.test;
    create or replace package body mkw.test
    as
    procedure t as
    begin
    ..... code
    end;
    end mkw.test;
    I get the error: PLS-00103: Symbool "." aangetroffen terwijl een van de volgende
    werd verwacht:
    What am I doing wrong?
    Thanks in advance.

    user10674103 wrote:
    Hi there,
    I'm trying to create a package in another schema, but I am getting an error when I do this.
    My script is as follow:
    i log in as user rwn.
    create or replace package mkw.test
    as
    procedure t;
    end mkw.test;
    create or replace package body mkw.test
    as
    procedure t as
    begin
    ..... code
    end;
    end mkw.test;
    I get the error: PLS-00103: Symbool "." aangetroffen terwijl een van de volgende
    werd verwacht:
    What am I doing wrong?
    Thanks in advance.Assuming you have permission to create packages in the other schema?
    Are you running this through SQL*Plus? If so, you really need to have "/" terminators after each object you are creating...
    e.g.
    create or replace package mkw.test
    as
      procedure t;
    end mkw.test;
    create or replace package body mkw.test
    as
      procedure t as
      begin
       ..... code
      end;
    end mkw.test;
    /

  • 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;

  • Snapshots refresh from package from another scheme

    *Also posted to Database:General!
    Hi all,
    i have a trouble while refreshing snapshots.
    First, i have a scheme where a package (for snapshots
    update) and snapshots themselves reside:
    package snp_update
    procedure update_snapshots
    is
    begin
    for s_name in ( SELECT owner, name
    FROM user_snapshots )
    loop
    dbms_snapshot.refresh (s_name.owner || '.' ||
    s_name.name, 'CA');
    end loop;
    end;
    end;
    Second, i have a scheme where reside only synonym to
    snp_update package (synonym name is syn_snp_update) and
    this scheme have granted 'execute' privilege on snp_update.
    But when i try to use it as
    begin
    syn_snp_update.update_snapshot;
    end;
    i have error: ORA-01031: insufficient privileges.
    But when i execute this pl/sql block from package
    owner's scheme - everything ok.
    Oracle: 8.0.5 on Sun Solaris 2.5
    Plz, help me.
    Maksym.

    How has your schema been granted the rights on SYN_SNP_UPDATE? A common cause of this problem is that the rights have been granted to a role. Oracle does not allow you to build procedures, etc using objects that you have been granted through a role. If this is the case you'll have to grant EXECUTE on SYN_SNP_UPDATE to your schema explicitly.
    Cheers, APCThrough
    grant execute on snp_update <synonym's owner schema>;
    BTW: Package's procedure is executing. Cursor (select ... from user_snapshots) retrieves first snapshot info in package's scheme and call to dbms_snapshot.refresh generates error.

  • 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.

  • Grant access to the dictionary of another schema

    Hello,
    I am a bit rusty with my knowledge about privileges, so I am not too sure about the best way to implement the following :
    User B must have access to all dictionary information about the objects of User A. User B does not need to perform SELECTs directly on the objects of User A. Security would be nice, but is not absolutely required, so an overkill could be OK.
    From what I tested, it looked like granting object privileges on dictionary objects and/or granting the SELECT ANY DICTIONARY privilege was never enough to see the lines corresponding to the objects of User A, and that it was required that User B also had SELECT privileges on all objects of User A.
    Is that really so ? And if yes, is there a better way to achieve this than periodically running a PL/SQL procedure ? Of course I would prefer to grant those privileges all in once, so that it would also take future objects into account.
    Any thoughts on this would be appreciated !

    actually, you should be more restrictive and grant only SELECT_CATALOG_ROLE instead of
    SELECT ANY DICTIONARYPersonally, I'm not so sure SELECT_CATALOG_ROLE is more restrictive...
    SQL> SELECT privilege, count(*)
      2  FROM dba_tab_privs
      3  WHERE grantee='SELECT_CATALOG_ROLE'
      4  GROUP BY privilege
      5  /
    PRIVILEGE                                 COUNT(*)
    DELETE                                            2
    EXECUTE                                           1
    INSERT                                            2
    SELECT                                         1144
    UPDATE                                            2
    5 rows selected.
    SQL> It also has the HS_ADMIN_ROLE.
    Probably these are just Oracle oversights/quirks and I guess may vary from version to version. So it's worth understanding what privileges everything has.
    Cheers, APC

  • Sql Developer - View source code of procedures, functions & packages in another schema

    Our developers need the ability to view procedures, function, packages etc. in the production database (using SQL DEVELOPER).  They don't have access to sign on as the owner of these
    objects in Production.  They must use their own limited access UserID for this purpose.
    This limited access UserID has been granted select privilege on DBA_SOURCE & DBA_OBJECTS.  The developers need the ability to view the source of these object via
    the tree view in SQL DEV.  They should be able to click on "other users" in the SQL DEV tree view and see a listing of the owner schema objects.  Then they should
    be able to select the desired object and view the source code.  These developers are used to using GUI interfaces.  Selecting from DBA_SOURCE would not be an
    option for them.
    I understand that if the limited user is granted SELECT ANY DICTIONARY or SELECT_CATALOG_ROLE then this functionality will work.  The problem is those
    privileges/roles  provide much more access than should be granted to these limited access users. Granting DBA to these users is also not an option.
    In TOAD and other end-user tools this functionality works when only select privilege on DBA_SOURCE & DBA_OBJECTS has been granted.  We need this same functionality
    in SQL DEV.
    While searching this forum and the internet, I see that other installations have this same issue.
    Please enhance SQL Developer with this functionality. 
    Thank you, ellen

    Just to double check that I'm interpreting the problem correctly, is the following true:
    select * from all_objects where object_name = 'DBA_SOURCE'
    returns nothing
    select * from dba_source where name = your PL/SQL module
    returns all the code

  • Call a Package in another schema  from a Trigger?

    Is there a method to call a package procedure from a trigger when the package exists within a different schema than the trigger (table)?
    Do you need a dblink to execute a procedure in a different schema within the same database?

    Hello,
    you need execute prvilege given to target schema on source package and you can create synonym in target schema as well. And you don't need dblink if the procedure resides in same schema or different schema in same database
    CREATE OR REPLACE TRIGGER myschema.test_trg
       BEFORE INSERT OR DELETE OR UPDATE
       ON test_table
       REFERENCING NEW AS new OLD AS old
       FOR EACH ROW
    DECLARE
    BEGIN
       -- How to pass parameters
       otherschema.mypkg.myproc (:new.id, :new.code);
    END;
    /Regards

  • How do I view package bodies in another schema ?

    For purposes of SOX and security/audit control, we log in under our network id's in our production environment. We have sourcecode compiled into Oracle seeded schemas ( APPS ) so that scheduled jobs are able to run with submitted from the Oracle Applications environment. We don't compile code into our personal network account areas.
    I know how to GRANT EXECUTE privs so that we can execute a package in another schema, but what I want to do is to be able to view the sourcecode in another schema. Compile into APPS but be able to see the package body from my network id schema account.
    I can't seem to find what the correct permission is anywhere. Granted I can look at DBA_SOURCE to get to it, but I want to use a tool like SQL Developer or TOAD to look at the code in a more presentable and easier to debug manner.
    Any help ?

    I did some more searching on the forum... seems its already a request... TOAD gives access to DBA_Views to resolve the issue... SQL Developer has not integrated that functionality yet, but forum entries seem to indicate that it is on the horizon.
    Thanks for responding though.
    ~Barry

  • Grant Permission base on Scheme ?

    Is there any way to grant permission base on scheme ??
    e.g.
    I want to allow user to select all table in another scheme. Beside grant permission for each table one by one, is there any way to do this ??

    There is no single privilege grant for this-- you'll have to grant privileges on individual objects. Of course, you can script these grants using a few lines of PL/SQL, i.e.
    DECLARE
      sqlStmt VARCHAR2(1000);
    BEGIN
      FOR x IN (SELECT * FROM user_tables)
      LOOP
        sqlStmt := 'GRANT SELECT ON ' || x.table_name ||
                   ' TO <<another user>>';
        EXECUTE IMMEDIATE sqlStmt;
      END LOOP;
    END;Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to GRANT SELECT on all the tables in 1 go?

    Hi
    I have many tables (close to 200) in my Schema. I want to grant SELECT ON ALL TABLES to another user. How do I achieve this in one go?
    Thanking you in advance,
    ...

    Although Justin has given a wonderful answer. You might also review the following threads;
    Grant select on a schema
    Re: Grant select on a schema
    grant select on
    grant select  on
    grant select on tables
    Re: grant select on tables
    Adith

  • Grant permission to a role.

    Oracle 11g R2 Windows.
    I have an oracle user, named user_1.  User_1 needs to be able to grant select on a table owned by another user, User_2, to a role. I keep getting the error ORA-01031: insufficient privileges.
    User_1 has the following system privileges:
    ALTER ANY INDEX
    ALTER ANY PROCEDURE
    ALTER ANY ROLE
    ALTER ANY SEQUENCE
    ALTER ANY TABLE
    ALTER ANY TRIGGER
    ALTER USER
    CREATE ANY INDEX
    CREATE ANY PROCEDURE
    CREATE ANY SEQUENCE
    CREATE ANY TABLE
    CREATE ANY TRIGGER
    CREATE ANY TYPE
    CREATE ANY VIEW
    CREATE DATABASE LINK
    CREATE SEQUENCE
    CREATE SYNONYM
    CREATE TABLE
    CREATE USER
    CREATE VIEW
    DELETE ANY TABLE
    DROP ANY INDEX
    DROP ANY PROCEDURE
    DROP ANY SEQUENCE
    DROP ANY TABLE
    DROP ANY TRIGGER
    DROP ANY VIEW
    EXECUTE ANY PROCEDURE
    EXECUTE ANY TYPE
    GRANT ANY PRIVILEGE
    GRANT ANY ROLE
    INSERT ANY TABLE
    SELECT ANY DICTIONARY
    SELECT ANY SEQUENCE
    SELECT ANY TABLE
    UNLIMITED TABLESPACE
    UPDATE ANY TABLE
    It has the following system roles:
    CONNECT
    DBA
    RESOURCE
    SELECT_CATALOG_ROLE
    What permissions must User_1 have to allow it to grant select on a table in another schema to a role? Both SYS and SYSDBA can do it, but I don’t want to give such elevated permissions to User_1.
    I have even granted SYSDBA to User_1 and I still get the ORA-01031 error!
    Thanks,
    Matthew

    I believe you're looking for the GRANT ANY OBJECT PRIVILEGE privilege.
    The ANY privileges are all very powerful privileges and they often create opportunities for crafty humans to do things that you might not have anticipated.  They are generally frowned upon heavily in any sort of audit situation.  I'd be very, very cautious about giving non-DBAs these privileges.
    It would make much more sense to me, particularly when you appear to want to restrict things to a single schema, to have a DBA user create a stored procedure that does the actual grant (implementing whatever validations, logging, etc. are appropriate) and grant the user the privilege to execute this stored procedure.
    Justin

  • 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

  • Grant permission to another's schema's package

    Dear buddies,
    I want to give access to another user to access a package in my schema.
    How should I be doing it?
    I saw in this page but how to refer to the different schema the package is residing?
    http://www.techonthenet.com/oracle/grant_revoke.php
    Please guide me.
    Thank You.
    Nith

    user645399 wrote:
    Dear buddies,
    I want to give access to another user to access a package in my schema.
    How should I be doing it?
    I saw in this page but how to refer to the different schema the package is residing?
    http://www.techonthenet.com/oracle/grant_revoke.php
    Please guide me.
    Thank You.
    NithDear Nith
    Here's the command:
    grant execute on your_schema.your_package to the_second_user;Kamran Agayev A.
    Oracle ACE
    My Oracle Video Tutorials - http://kamranagayev.wordpress.com/oracle-video-tutorials/

Maybe you are looking for

  • Data Recovery - External Hard Drive

    Hi, I have recently copied over a folder on my iOmega (Prestige Portable) External Hard Drive with a folder from my Power Book Hard Drive, with the replace all. What I need to know is there a way to step back to the point before I copied over this fo

  • Has anyone with the iPhone had a problem with 7.3 itunes?

    I'm curious to know if people who bought the iphones have had the same problems with 7.3 itunes that seems so prevalent on the discussion board (like getting the error message in saving the library file, or frequent crashes). I'd love to know, becaus

  • Consuming Web Service ( How to pass multiple inputs and retrieve dataset)

    I am new to ADF and Web service. In the current project, I have to consume a web service ( through WSDL). Created the pages as per the following tutorials. http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_14/jdtut_11r2_14.html As per the step

  • Acrobat 7 sdk

    hi, is there sdk available for acrobat 7. if yes,how shall i get the setup or how can download prabudass

  • Renaming and Joining Clips

    The instructions in iMovie Help clearly state it is possible rename clips in the Clips Pane, not just the Clip Viewer. In iMovie 3.0.3 which I am using, it lets me rename them in the Clip Viewer just fine by selecting and retyping the name. Once in t