ORA-00942在授权选择中

时间:2016-07-18 10:00:00

标签: sql oracle sqlplus grant

我尝试创建一个只能从Tables(ReadOnly

中选择的新Oracle用户

我已经在SYS架构上执行了下一行:(如7502438

1 - 创建用户

CREATE USER my_user IDENTIFIED BY my_password DEFAULT TABLESPACE users  TEMPORARY TABLESPACE temp;

2 - 授予创建会话

GRANT CREATE SESSION to my_user;

3 - 创建角色

CREATE ROLE my_role;

4 - 授予从新角色中选择的角色

BEGIN
  FOR x IN (SELECT * FROM dba_tables WHERE owner='OWNER')
  LOOP
    EXECUTE IMMEDIATE 'GRANT SELECT ON OWNER.' || x.table_name || 
                                  ' TO my_role';
  END LOOP;
END;

5 - 将角色授予用户

GRANT my_role TO my_user;

所以在第4部分,我收到了这个错误

ORA-00942: table or view does not exist
ORA-06512: at line 4
00942. 00000 -  "table or view does not exist"
*Cause:    
*Action:

所有想法?

1 个答案:

答案 0 :(得分:1)

也许DBA_TABLES查询的结果中列出了丢弃的表。

https://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_2105.htm#REFRN20286