on sql Grant

I grant the emp table to the user scott to the criterion of the user, as follows:
SQL > grant select on scott.emp to test

Then I use the connection test and visit the table emp
SQL > select * from scott.emp

Now, I want to visit the table emp as follows, but he failed.
SQL > select * from EMP

I want to know how to change the grant statement and make above sql can work well?

Thank you

EdwardKing wrote:
I tried following:
Under sys s/n,.
SQL > CREATE SYNONYM EMP ON scott.emp
SQL > ALTER SESSION SET current_schema = SCOTT
Then I connect with the test
SQL > select * from EMP
ORA-00942:

Where's the harm? Thank you

1. you created a synonym private sys_dba. You must create to test.
2. connect with the current_schema return to test test changes. Change it if after you login as test.

So, either:

connection test
create synonym emp for scott.emp;
Select * from emp;

or:

connect [any user who created public synonym privileges]
create public synonym emp for scott.emp;
connection test
Select * from emp;

or:

connection test
ALTER session set current_schema = SCOTT;
Select * from emp;

Tags: Database

Similar Questions

  • Granting of privileges through role does not not for PL/SQL

    Version: 11.2.0.2


    In our shop, we don't grant privileges directly to a user, give us it to a role, and grant this role to user scheduled grantee.

    Granting of privileges through a role seems to be fine with the SQL engine. But it does not PL/SQL engine.

    In the example below, the GLS_DEV user is granted access SELECT on SCOTT.pets table through a role called tstrole. GLS_DEV can select the SQL table. But does not seem to PL/SQL engine to find out.

    Reproduce the problem:
    SQL> show user
    USER is "SCOTT"
    
    SQL> select * from pets;
    
    NAME
    -----------------------------------
    PLUTO
    
    
    SQL> conn / as sysdba
    Connected.
    
    
    SQL> create user GLS_DEV identified by test1234 default tablespace TSTDATA;
    
    User created.
    
    SQL> alter user GLS_DEV quota 25m on TSTDATA;
    
    User altered.
    
    
    SQL> grant create session, resource to GLS_DEV;
    
    Grant succeeded.
    
    
    --- Granting SELECT privilege on scott.pets to tstrole and then grant this role to GLS_DEV.
    
    SQL> conn / as sysdba
    Connected.
    SQL>
    SQL> create role tstrole;
    
    Role created.
    
    SQL> grant select on scott.pets to tstrole;
    
    Grant succeeded.
    
    SQL> grant tstrole to GLS_DEV;
    
    Grant succeeded.
    
    SQL> conn GLS_DEV/test1234
    Connected.
    SQL>
    SQL> select * From scott.pets;
    
    NAME
    -----------------------------------
    PLUTO
    
    ---- All fine till here. From SQL engine , GLS_DEV user can SELECT scott.pets table.
    
    --- Now , I am going to create a PL/SQL object in GLS_DEV which tries to refer scott.pets
    
    SQL> show user
    USER is "GLS_DEV"
    
    
    create or replace procedure my_proc
    is
    myvariable varchar2(35);
    
    begin
         select name into myvariable from scott.pets ;
    
         dbms_output.put_line(myvariable);
    
    end my_proc;
    /
    
    Warning: Procedure created with compilation errors.
    
    SQL> show errors
    Errors for PROCEDURE MY_PROC:
    
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    6/2      PL/SQL: SQL Statement ignored
    6/41     PL/SQL: ORA-01031: insufficient privileges
    
    SQL>
    SQL> 6
      6*    select name into myvariable from scott.pets ;
    
    
    --- PL/SQL Engine doesn't seem to know that GLS_DEV has select privilege on scott.pets indirectly granted through a role
    
    --- Fix
    --- Instead of granting privilege through a role, I am granting the SELECT privilege on scott.pets to GLS_DEV directly.
    --- The error goes away, I can compile and execute the procedure !!
    
    SQL> conn / as sysdba
    Connected.
    SQL>
    SQL> grant select on scott.pets to GLS_DEV;
    
    Grant succeeded.
    
    SQL> conn GLS_DEV/test1234
    Connected.
    SQL>
    SQL> create or replace procedure my_proc
    is
    myvariable varchar2(35);
    
    begin
            select name into myvariable from scott.pets ;
    
            dbms_output.put_line(myvariable);
    
    end my_proc;  2    3    4    5    6    7    8    9   10
     11  /
    
    Procedure created.
    
    SQL> set serveroutput on
    SQL> exec my_proc;
    PLUTO
    
    PL/SQL procedure successfully completed.
    Has anyone encountered the same problem?

    N.Page wrote:
    Ok. Thank you all.
    There is no work around for this like using the clause AUTHID or something?

    Yes. using AUTHID (Summoner vs rights define) can make a difference.
    However it makes sense that pl/sql uses roles a little differently. Although at first glance, it is hard to see why. The reasoning is similar to the difference between a user and a schema.

    A user is a person who connects to a database. It has a role and this role defines what privileges he gets when you work with data.
    A schema consists of several objects that reside in the database. A package is also such an object. This package is valid, it is necessary to have all privileges directly. A role can be enabled and is a sort of temporary right. A direct subsidy has a permanent status. A user will only get the right to run this package/procedure/function. The package is a type of user interface. It encapsulates the privileges necessary to do something about this user.

    The logical problem happens only when the user and packaging are in the same scheme. The best approach is to have the package in the normal pattern and have a separate "schema access" with which the user connects. Give then execute privs on the package for this second scheme.

  • Grant execute on DBMS_REPUTIL fails

    Hello

    I just installed Oracle Database 11 g Release 11.2.0.4.0 - 64 bit Production, and I need to run on DBMS_REPUTIL of user for the compatibility of the trigger. I get the error:

    SQL > GRANT EXECUTE ON DBMS_REPUTIL to THE PUBLIC;

    GRANT EXECUTE ON DBMS_REPUTIL TO THE PUBLIC

    *

    ERROR on line 1:

    ORA-00942: table or view does not exist

    SQL > grant execute on DBMS_REPUTIL to webusr

    *

    ERROR on line 1:

    ORA-00942: table or view does not exist

    What is the problem with the grant command? Can anyone suggest how to grant execute on this package?

    Here is my version of oracle:

    SQL > select * from v version $;

    BANNER

    --------------------------------------------------------------------------------

    Oracle Database 11 g Release 11.2.0.4.0 - 64 bit Production

    PL/SQL Release 11.2.0.4.0 - Production

    CORE Production 11.2.0.4.0

    AMT for Linux: Version 11.2.0.4.0 - Production

    NLSRTL Version 11.2.0.4.0 - Production

    Thank you!

    USER issuing the GRANT doesn't have a necessary privilege.

    SQL > connect scott/tiger

    Connected.

    SQL > GRANT EXECUTE ON DBMS_REPUTIL TO THE PUBLIC;

    GRANT EXECUTE ON DBMS_REPUTIL TO THE PUBLIC

    *

    ERROR on line 1:

    ORA-01031: insufficient privileges

    SQL > connect / as sysdba

    Connected.

    SQL > GRANT EXECUTE ON DBMS_REPUTIL TO THE PUBLIC;

    Grant succeeded.

  • find roles that grant privileges to the same owner


    I did an impdo and I saw on a lot of these types of errors:

    ORA-39083: Type than object_grant cannot be created with the object error:

    ORA-01749: you cannot GRANT/REVOKE privileges to yourself

    Because sql is:

    GRANT SELECT ON "SMART." "" SOURCE_SYSTEM_DIMENSION "TO"SMART ".

    Smart notice to smart...   Can someone give me a SQL that will allow me to generate a file that I can run to eliminate these types of cases.

    Notte is should show the operatation in this "select" cases where it has failed.

    Thank you all

    It looks like a privileged granted user privileges on the tables of smart chip, which is absurd, but legal.

    SQL > create an identified by a tablespace default user user

    2 unlimited quota on users;

    Created by the user.

    SQL > grant create table, create a session to one.

    Grant succeeded.

    SQL > conn a/a.

    Connected.

    SQL > create table t (ID, descr varchar2 (10));

    Table created.

    SQL > conn /.

    Connected.

    SQL > grant select on Abdel to one.

    Grant succeeded.

    dev1 > select table_name, privilege, constituent, dealer

    2 of dba_tab_privs

    3 where dealer = "A";

    DEALER PRIVILEGE TABLE_NAME GRANTOR

    ------- ------- --------- ----------

    A A T SELECT

    dev1 > revoke select on a.t a;

    Revoke succeeded.

    dev1 > conn a/a.

    Connected.

    dev1 > grant select on t for one;

    Grant select on t for a

    *

    ERROR on line 1:

    ORA-01749: you cannot GRANT/REVOKE privileges to yourself

    To reverse the invalid grant, you can use something like this to generate a script:

    Select "revoke". privilege: ' on ' | conceding |'. ' ||

    table_name |' a ' | dealer | « ; »

    of dba_tab_privs

    where dealer = constituting;

    Or you can use a similar query in an anonymous block, immediate use of execute to execute the revoke command.  The user will have full privileges on the objects that they own.

    John

  • How can I determine what were the privileges granted to the PUBLIC?

    I don't know 'out of the box' privileges by default Oracle, but rather the privileges that have been granted since the day 0.

    SQL > select * from dba_sys_privs where dealer = "PUBLIC";

    no selected line

    SQL > grant create any table to the public;

    Grant succeeded.

    SQL > select * from dba_sys_privs where dealer = "PUBLIC";

    DEALER PRIVILEGE SMA

    ------------------------------ ---------------------------------------- ---

    PUBLIC CREATE ANY TABLE NO.

    SQL > revoke create any table of public;

    Revoke succeeded.

    SQL > select * from dba_sys_privs where dealer = "PUBLIC";

    no selected line

    SQL >

    The PUBLIC role is a special role that each database user account is automatically when the account is created. By default, it has no privileges granted to it, but there are many grants, especially for Java objects.


    The same binding, which was provided by a member.


    DBA_ROLE_PRIVS - roles granted to users and roles

    ROLE_ROLE_PRIVS - roles that were granted to roles

    ROLE_SYS_PRIVS - privileges granted to the roles system

    ROLE_TAB_PRIVS - Table privileges granted to roles

    Concerning

    Girish Sharma

  • Cannot query a view in PL/SQL package but it can query in SQL * more

    Hello

    Logged on as a user, I can query the table DBA_SEGMENTS, but I can't question via a slider or select from a PL/SQL package.

    I get the following error message:

    LINE/COL ERROR

    -------- -----------------------------------------------------------------

    28/4 PL/SQL: statement ignored

    33/5 PL/SQL: ORA-00942: table or view does not exist

    28 select

    29                             count(*)

    30 in

    31                             n

    32 of

    33 dba_segments;


    Can someone explain to me what is the missing privilege that I need?

    Thank you in advance.

    Kind regards.

    It seems that you have granted to dba_segments by role.

    To use this object in pl/sql or sp, you need directly.

    Ask your dba to grant:

    SQL > grant select on dba_segments to your_user;

    Mustafa DOGANAY

    http://Doganay.WordPress.com

  • Grant truncate HR. EMP to SCOTT

    Hi all

    11.2.0.1

    What specific privilege can grant truncate table to a user?

    I'm confused:

    Connect as SYS:

    SQL > grant all on human resources. EMP to SCOTT;

    Grant succeeded.

    Connect as SCOTT:

    SQL > truncate table HR. EMP;

    Table truncated.

    Connect as SYS:

    SQL > revoke all on human resources. SCOTT EMP;

    Revoke succeeded.


    Connect as SCOTT:

    SQL > truncate table HR. EMP;

    Table truncated.


    Why SCOTT might still truncate the table?


    Thank you



    I'm going to assume that these are not temporary tables in fact (that is, they are not global temporary tables)

    CREATE PROCEDURE table_owner.truncate_table( p_table_name in varchar2 )
    
    AS
    BEGIN
    IF( p_table_name IN (<>))
    THEN
       EXECUTE IMMEDIATE 'TRUNCATE TABLE ' || p_table_name;
    END IF;
    END;
    

    Of course, you can add additional logging logic, or you can allow different users to truncate different tables...

    Justin

  • Which granted CREATE a PUBLIC SYNONYM for user SCOTT?

    version: 11.2.0.3
    Operating system: Solaris 10

    Auditing is enabled in our database.
    SQL> show parameter audit_trail
     
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    audit_trail                          string      DB
    Of DBA_SYS_PRIVS, we have confirmed that one of our DBA colleagues gave some risky privileges like CREATE PUBLIC SYNONYM, SELECT ANY TABLE... etc. to the user SCOTT.

    We would like to find out 2 things
    1. the SQL GRANT
    2. the date and time on which the statetement GRANT was pulled


    How can we find it?

    Y.Ramlet wrote:
    version: 11.2.0.3
    Operating system: Solaris 10

    Auditing is enabled in our database.

    SQL> show parameter audit_trail
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    audit_trail                          string      DB
    

    Of DBA_SYS_PRIVS, we have confirmed that one of our DBA colleagues gave some risky privileges like CREATE PUBLIC SYNONYM, SELECT ANY TABLE... etc. to the user SCOTT.

    We would like to find out 2 things
    1. the SQL GRANT

    You will have no SQL in the audit trail, because you have not configured the parameter correctly. You must audit_trail = db, extended to get the SQL code.

    2. the date and time on which the statetement GRANT was pulled

    You will have anything unless you have enabled auditing for the instruction given with
    Check create public synonym;

    How can we find it?

    You can't until you configure the audit in an appropriate manner.

  • GRANT failed: password file missing or disabled

    Hello

    I created the password help file
    orapwd FILE = orapwprj ENTRIES = 30 (where prj is the name of the instance)



    SQL > show parameter remote_login_passwordfile

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    Remote_login_passwordfile string EXCLUSIVE


    SQL > grant sysdba to Arou.
    grant sysdba to Arou
    *
    ERROR on line 1:
    ORA-01994: GRANT failed: password file missing or disabled

    Try to give the full path of the file. Check if the file is created under the folder$ ORACLE_HOME\dbs\

    SID is case-sensitive, try file = $ORACLE_HOME\dbs\PWD

    Published by: Vieira on August 30, 2012 21:52

  • Is it not view DBA_ see the privileges granted to a role?

    DB version: 11.2

    I couldn't find DBA_ views that would list all the privileges granted to a role. Finally, I had to assign the role to a user and then sign in as a user who has granted and then query view ROLE_TAB_PRIVS. A DBA, I can not connect in business patterns to check for this.


    The scenario
    ==============
    SCOTT schema has two tables: HRTB_EMP_MASTER and HELLOWORLD
    I want to grant SELECT on these two tables privileges to another user called TESTUSER but not directly. through roles

    SQL> conn / as sysdba
    Connected.
    
    SQL> grant create role to testuser;
    
    Grant succeeded.
    
    SQL> conn testuser/test123
    Connected.
    SQL>
    SQL> create role testuser_ro;  
    
    Role created.
    
    SQL> conn / as sysdba
    Connected.
    SQL> grant select on scott.hrtb_emp_master to testuser_ro;         --- > Granting the SELECT priv to the role first
    
    Grant succeeded.
    
    SQL> grant select on scott.helloworld to testuser_ro;               
    
    Grant succeeded.
    
    SQL> SELECT ROLE, OWNER, TABLE_NAME, PRIVILEGE FROM ROLE_TAB_PRIVS where owner = 'SCOTT';  ----> This won't work because I am connected as SYS
                                                              ----> ROLE_TAB_PRIVS is user specific view
    no rows selected
    Since I couldn't find a DBA view that will have the privileges granted to a role, I have granted the role to the user, I had to open a session to the user (against our security policy) and the query
    ROLE_TAB_PRIVS.

    SQL > grant testuser_ro to testuser;

    Grant succeeded.

    SQL > PRIVILEGE OF ROLE_TAB_PRIVS, TABLE_NAME, OWNER, SELECT ROLE where owner = 'SCOTT ';

    no selected line

    SQL> conn testuser/test123
    Connected.
    
    
    SQL> SELECT ROLE, OWNER, TABLE_NAME, PRIVILEGE FROM ROLE_TAB_PRIVS where owner = 'SCOTT';
    
    ROLE            OWNER           TABLE_NAME           PRIVILEGE
    --------------- --------------- -------------------- ----------
    TESTUSER_RO     SCOTT           HELLOWORLD           SELECT
    TESTUSER_RO     SCOTT           HRTB_EMP_MASTER      SELECT

    You must look for beneficiary, no owner

    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> create role r1;
    
    Role created.
    
    SQL> grant select on sys.v$database to r1;
    grant select on sys.v$database to r1
                        *
    ERROR at line 1:
    ORA-02030: can only select from fixed tables/views
    
    SQL> grant select on sys.v_$database to r1;
    
    Grant succeeded.
    
    SQL> select grantee, privilege, owner, table_name from dba_tab_privs where grantee='R1';
    
    GRANTEE         PRIVILEGE                                OWNER           TABLE_NAME
    --------------- ---------------------------------------- --------------- ------------------------------
    R1              SELECT                                   SYS             V_$DATABASE
    
  • Problem of Grant/revoke / Clarification

    SQL> conn sys as sysdba
    Enter password:
    Connected.
    SQL> show user
    USER is "SYS"
    -- Create a user
    SQL> create user test identified by test ;
    
    User created.
    -- grant him the create table system privilege
    SQL> grant create session,create table to test;
    
    Grant succeeded.
    
    SQL> conn test/test
    Connected.
    SQL> create table t ( a number);
    
    Table created.
    
    SQL> disconnect
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64
    bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> conn sys as sysdba
    Enter password:
    Connected.
    SQL> revoke create table from test;
    
    Revoke succeeded.
    
    SQL> conn test/test
    Connected.
    SQL> create table tr(a number) ;
    create table tr(a number)
    *
    ERROR at line 1:
    ORA-01031: insufficient privileges
    
    
    SQL> alter table t add b number;
    
    Table altered.
    
    SQL> drop table t;
    
    Table dropped.
    Hi all

    I started to go through the basics of the DBA to create a user. I came up with a scenario where it is difficult for me to understand or justify the following scenario.

    Step 1: Create a user(Eg: test) and grant create session and create system table privileges
    Step 2: Test user connection and create a table called you
    Step 3: Connect as sysdba and revoke the privilege to create test user table
    Step 4: Connect as user test and try to create a table where the user are not able to create due to insufficient privileges, but you are allowed to modify or delete the table

    Question:

    How is it possible to modify or delete a table where there is no privilege is available except create the privilege of the session of the user (test)

    Please explain the above scenario

    Thanks in advance
    Carole Kumar

    >
    Thanks for the reply and is not the same course, but the user has the privilege to create session only. then how it is possible to modify or delete?
    >
    If you had read that the doc mentioned that you would have found that there is no drop or modify privileges to the user owner of the table.

    See 'Paintings of a fall' in the DBA Guide
    >
    To remove a table that you no longer need, use the DROP TABLE statement. The table must be contained in your schema or you must have the DROP ANY TABLE system privilege.
    >
    See 'Edit the tables' in the DBA Guide
    http://docs.Oracle.com/CD/B28359_01/server.111/b28310/tables006.htm
    >
    You change a table using the ALTER TABLE statement. To modify a table, the table must be contained in your schema or you must have the privilege to ALTER object for the table or the privilege to ALTER ANY system TABLE.
    >
    And just because your user name is able to create the table when grant you CREATE TABLE does not mean that the user could actually INSERTING records in the table.

  • How to use the API of PL/SQL DBFS

    Hi guys,.

    I re-post this question to see if someone can help out me. I'm trying to use the API of PL/SQL DBFS to manipulate the files stored in DBFS.

    Details of the environment:
    Windows 7 or 5.5 OEL (I tried both platforms)
    Database: Oracle DB EE 11.2.0.2
    IDE: SQLDeveloper on Windows 7

    I have two users, DBFS_USER, who is the shop owner DBFS and MYUSER that connects to the store to manipulate files using the API of PL/SQL DBFS.

    Creation scripts:
    -----------------
    Connect / as sysdba;

    Dbfs_ts CREATE TABLESPACE DATAFILE 'D:\oracle\oradata\orcl\dbfs01.dbf' SIZE 1 M AUTOEXTEND ON NEXT 1 M;

    -create users
    create dbfs_user user identified by dbfs_user quota default tablespace unlimited dbfs_ts on dbfs_ts;
    create myuser identified by myuser;

    -grant the role
    GRANT RESOURCES, CREATE VIEW, CREATE SESSION, DBFS_ROLE, CREATE TABLE TO dbfs_user.
    GRANT RESOURCES, CREATE VIEW, CREATE SESSION, DBFS_ROLE, CREATE TABLE TO myuser.

    -create a filesystem (such as DBFS_USER)
    connect dbfs_user/dbfs_user;

    exec dbms_dbfs_sfs.createFilesystem ('STAGING_AREA_FS');

    exec dbms_dbfs_content.registerStore ('STAGING_AREA_FS', 'posix', 'DBMS_DBFS_SFS');

    dbms_dbfs_content.mountStore exec ('STAGING_AREA_FS', 'staging_area');

    commit;

    -export store STAGING_AREA_FS (as DBFS_USER)

    exec dbms_dbfs_sfs.exportFilesystem ('STAGING_AREA_FS');

    -Check the names of table (like MYUSER)
    connect myuser/myuser;

    -He can't see (without brackets)
    Select * from table (dbms_dbfs_content.listMounts);

    -Note at the bottom of the table table_name
    Select * from table (dbms_dbfs_sfs.listTables);

    -Mount as MYUSER (example with SFS table_name $ _FST_32)
    dbms_dbfs_sfs.registerFilesystem exec ('MYUSER_FS', 'DBFS_USER', ' FS$ _FST_32');

    exec dbms_dbfs_content.registerStore ('MYUSER_FS', 'posix', 'DBMS_DBFS_SFS');

    dbms_dbfs_content.mountStore exec ('MYUSER_FS', 'staging_area');

    commit;

    -verification of Mount (like MYUSER)

    Select * from table (dbms_dbfs_content.listMounts);

    Select the path in dbfs_content;


    CREATE a STORED PROC (like MYUSER)
    ----------------------------

    CREATE OR REPLACE PACKAGE MYUSER_PKG

    CreateDirectory function
    (P_File_Path IN VARCHAR2,
    P_ErrMsg OUT VARCHAR2)
    return number;

    END MYUSER_PKG;

    /


    CREATE OR REPLACE PACKAGE BODY MYUSER_PKG

    CreateDirectory function
    (P_File_Path IN VARCHAR2,
    P_ErrMsg OUT VARCHAR2)
    Return number
    IS
    l_Return NUMBER;
    l_props DBMS_DBFS_CONTENT. PROPERTIES_T;
    BEGIN
    l_Return: = 0;

    () DBMS_DBFS_CONTENT.createDirectory
    path = > P_File_Path,
    Properties = > l_props);

    RETURN l_Return;
    EXCEPTION
    WHILE OTHERS THEN
    l_Return: = NVL (SQLCODE,-1);
    P_ErrMsg: = SQLERRM;
    RETURN l_Return;
    CreateDirectory END;

    END MYUSER_PKG;

    /

    When you compile the package, I get this error:
    Error (9,11): PLS-00201: identifier 'DBMS_DBFS_CONTENT' must be declared
    Error (9,11): PL/SQL: ignored element
    Error (13.3): PL/SQL: statement ignored
    Error (15,19): PLS-00320: the declaration of the type of the expression is incomplete or incorrect

    How can I solve the problem in the error message? I'm not an expert in DB. I used this reference documentation: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e18294/adlob_client.htm#CIHDEJAA

    Thanks in advance.

    CAPPA

    You must directly grant the privileges of DBFS_ROLE because roles are not enabled in stored PL/SQL:

    SQL> select* from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Solaris: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    
    SQL> show user
    USER is "SYS"
    SQL>
    SQL> create user myuser identified by myuser;
    
    User created.
    
    SQL> GRANT CREATE SESSION, RESOURCE, CREATE VIEW, DBFS_ROLE, CREATE TABLE TO myuser;
    
    Grant succeeded.
    
    SQL>
    SQL> begin
      2  for x in (select privilege, table_name
      3           from dba_tab_privs
      4           where grantee='DBFS_ROLE')
      5  loop
      6   execute immediate 'grant ' || x.privilege || ' on ' || x.table_name
      7   || ' to myuser ';
      8  end loop;
      9  end;
     10  /
    begin
    *
    ERROR at line 1:
    ORA-22812: cannot reference nested table column's storage table
    ORA-06512: at line 6
    
    SQL>
    SQL> connect myuser/myuser
    Connected.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE MYUSER_PKG IS
      2  Function CreateDirectory
      3  (P_File_Path IN VARCHAR2,
      4  P_ErrMsg OUT VARCHAR2)
      5  return Number;
      6  END MYUSER_PKG ;
      7  /
    
    Package created.
    
    SQL> show errors
    No errors.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY MYUSER_PKG  IS
      2  Function CreateDirectory
      3  (P_File_Path IN VARCHAR2,
      4  P_ErrMsg OUT VARCHAR2)
      5  return Number
      6  IS
      7  l_Return NUMBER;
      8  l_props DBMS_DBFS_CONTENT.PROPERTIES_T;
      9  BEGIN
     10  l_Return := 0;
     11  DBMS_DBFS_CONTENT.createDirectory (
     12  path => P_File_Path,
     13  properties => l_props);
     14  RETURN l_Return;
     15  EXCEPTION
     16  WHEN OTHERS THEN
     17  l_Return := NVL(SQLCODE, -1);
     18  P_ErrMsg := SQLERRM;
     19  RETURN l_Return;
     20  END CreateDirectory;
     21  END MYUSER_PKG ;
     22  /
    
    Package body created.
    
    SQL> show errors
    No errors.
    

    You should check why some GRANT statement fails if you have another problem with the other piece of code.

  • error in grant execute to the public on the package

    Hello
    I have a package that works with my user but when I try to run on this package that I receive
      
    declare
          v_id number;
         begin
              v_id := liste_pkg_lista.liste_lista_func(9);
            dbms_output.put_line(v_id);
    end;
    SQL> /
    9
    
    PL/SQL procedure successfully completed.
    
    SQL> grant execute on liste_pkg_lista.liste_lista_func to public;
    grant execute on liste_pkg_lista.liste_lista_func to public
                                     *
    ERROR at line 1:
    ORA-04042: procedure, function, package, or package body does not exist
    can you tell me how to run on it to the public?

    Thank you

    Coco wrote:
    Hello
    I have a package that works with my user but when I try to run on this package that I receive

    
    declare
    v_id number;
    begin
    v_id := liste_pkg_lista.liste_lista_func(9);
    dbms_output.put_line(v_id);
    end;
    SQL> /
    9
    
    PL/SQL procedure successfully completed.
    
    SQL> grant execute on liste_pkg_lista.liste_lista_func to public;
    grant execute on liste_pkg_lista.liste_lista_func to public
    *
    ERROR at line 1:
    ORA-04042: procedure, function, package, or package body does not exist
    

    can you tell me how to run on it to the public?

    Thank you

    Grant execute on liste_pkg_lista to public;

  • Problem with granting/revoking of privileges on the SYSTEM (and other) tablespace

    Hello

    I'm new to this forum, so I hope I posted this topic in the wrong section.

    My problem is the following:

    I need to create a user that should have access to certain storage spaces. I read a lot of articles, tutorials, etc. (and google it of course :)), but I couldn't find a solution to my problem. I created a user with this command in SQLPLUS:

    SQL > create user identified by test test
    2 default tablespace users
    3 quota 5 m on users;

    Privileges to user test given, like this:

    SQL > grant connect to test;

    Grant succeeded.

    SQL > grant create table to test;

    Grant succeeded.

    OK, so the user must be able to connect and create dashboards on USERS tablespace. My problem is that the user can also create tables on other tablespaces. Also on the SYSTEM tablespace - I don't want. I have not affected all contingent on any other tablespace users, yet it can create arrays of anywhere. I'm obviously something wrong, since I tried this on two different installations of Oracle (we were under Linux with D Oracle version 11.2.0.2.0 and the other was Windows with 11.2.0.1.0) and I got the same result.

    These are all tablespaces on my db instance if she will give useful information:

    TABLESPACE_NAME
    ---------------
    SYSTEM
    SYSAUX
    UNDOTBS1
    TEMP
    USERS
    EXAMPLE OF

    P.S.: I also tried: SQL > change the quota of test user 0 on SYSTEM; but it did not help. The user can still create tables on the SYSTEM tablespace.

    I used this test user command to create a table on system tablespace:

    SQL > create table testtest (num number (8)) tablespace SYSTEM;

    Please, I would appreciate greatly any help on this.
    Thank you in advance.

    Blaz

    Edited by: 884002 08-Aug-2011 04:51

    Always the same questions frequently asked in this forum, so boring. Always of people who state they don't read the documentation, but still has not found an answer. So boring.

    Provide the output of the following

    Select *.
    of session_roles;

    Select *.
    of session_privs
    where privilege like '% UNLIMITED '.
    ;

    Select *.
    of user_ts_quotas

    logged in as user test.

    -----------------
    Sybrand Bakker
    Senior Oracle DBA

  • Can not GRANT multiple privileges (separated by commas) at once?

    DB version: 11.1
    Operating system platform: AIX

    Connected to sqlplus in AIX.
    SQL> grant LMRL , 
     CREATE LIBRARY ,
     EXECUTE ON SYS.UTL_FILE , 
     UNLIMITED TABLESPACE,
     EXECUTE ON SYS.DBMS_PIPE ,
     EXECUTE ON SYS.UTL_FILE,
     select on DBA_OBJECTS,
     select on DBA_ERRORS to  
     myuser;  2    3    4    5    6    7    8    9  
    grant LMRL ,
          *
    ERROR at line 1:
    ORA-00990: missing or invalid privilege
    
    -- Removing LMRL role
    
    SQL> grant 
     CREATE LIBRARY ,
     EXECUTE ON SYS.UTL_FILE , 
     UNLIMITED TABLESPACE,
     EXECUTE ON SYS.DBMS_PIPE ,
     EXECUTE ON SYS.UTL_FILE,
     select on DBA_OBJECTS,
     select on DBA_ERRORS to  
     myuser;  
      2    3    4    5    6    7    8    9   CREATE LIBRARY ,
     *
    ERROR at line 2:
    ORA-00990: missing or invalid privilege
    
    -- Removed the new lines and put everything on one line
    grant CREATE LIBRARY ,EXECUTE ON SYS.UTL_FILE , UNLIMITED TABLESPACE,EXECUTE ON SYS.DBMS_PIPE ,EXECUTE ON SYS.UTL_FILE,select on DBA_OBJECTS,select on DBA_ERRORS to myuser;  
    ERROR at line 1:
    ORA-00990: missing or invalid privilege
    But, when I GRANT these privileges/roles individually, it works
    SQL> grant LMRL to  myuser;
    
    Grant succeeded.
    
    SQL> grant execute on SYS.UTL_FILE to  myuser;
    
    Grant succeeded.
    
    SQL> grant create library to myuser;
    
    Grant succeeded.
    
    SQL> grant UNLIMITED TABLESPACE to myuser;
    
    Grant succeeded.
    
    SQL> grant select on DBA_OBJECTS to myuser;
    
    Grant succeeded.
    I don't know if this only happens when I connect locally to AIX. For this DB, I can ' connect remotely and test.

    You cannot mix access privileges with a single command object privileges. You can issue multiple access privileges to a single command.

    Similarly, you cannot combine several privileges object in a single command.

    SQL> create user TEST_A identified by TEST_A;
    
    User created.
    
    SQL> grant CREATE LIBRARY ,EXECUTE ON SYS.UTL_FILE , UNLIMITED TABLESPACE to TEST_A;  -- mixed privileges
    grant CREATE LIBRARY ,EXECUTE ON SYS.UTL_FILE , UNLIMITED TABLESPACE to TEST_A
          *
    ERROR at line 1:
    ORA-00990: missing or invalid privilege
    
    SQL> grant CREATE LIBRARY, UNLIMITED TABLESPACE to TEST_A;   -- multiple system privileges
    
    Grant succeeded.
    
    SQL> grant EXECUTE ON SYS.DBMS_PIPE ,EXECUTE ON SYS.UTL_FILE to TEST_A;   -- multiple object privileges return a different error
    grant EXECUTE ON SYS.DBMS_PIPE ,EXECUTE ON SYS.UTL_FILE to TEST_A
                                   *
    ERROR at line 1:
    ORA-00905: missing keyword
    
    SQL> grant EXECUTE ON SYS.DBMS_PIPE to TEST_A;
    
    Grant succeeded.
    
    SQL> grant EXECUTE ON SYS.UTL_FILE to TEST_A;
    
    Grant succeeded.
    
    SQL>
    SQL>
    

    Hemant K Collette

Maybe you are looking for