Oracle将特权用户A授予用户B

时间:2018-10-03 01:54:57

标签: oracle privileges


    I create user A and B with system admin
    -- CREATE USER1 SQL
    CREATE USER USERA IDENTIFIED BY 123456 ;
    GRANT CREATE SESSION TO USERA;
    CREATE USER USERB IDENTIFIED BY 123456 ;
    GRANT CREATE SESSION TO USERB;

    and set Privileges to USERA
    -- SYSTEM PRIVILEGES USERA
    GRANT CREATE TABLE TO USERA;
    GRANT DELETE ANY TABLE TO USERA;
    GRANT GRANT ANY PRIVILEGE TO USERA;

    and create table by USERA

    CREATE TABLE tableA 
    (ID VARCHAR2(5)
    , DATA VARCHAR2(20) );

    and create Privileges to USERB by USERA set select tableA
    GRANT SELECT ON tableA to USERB;

    but USERB can't select tableA 
    ERROR:ORA-00942: table or view does not exist

    How do I solve the problem?

1 个答案:

答案 0 :(得分:0)

如果您没有为表指定所有者,Oracle将假定所有者为当前用户。

a {
    display: block;
    ...
}

为避免此问题,通常建议创建一个本地同义词(由userb拥有):

select * from usera.tablea;

现在,userb可以查询表了:

create synonym userb.tablea for usera.tablea;