我正在尝试从特定用户的两个不同表中获取角色和权限。我的疑问是:
tbl_order_item
我结束了这个:
orderItems
当用户没有多个角色/权限时,这很好,但对于像SYS这样的用户,我最终会得到orderItems
有没有办法让查询结果更好?我错过了加入吗?
PS:我正在研究oracle 11g。
如果你能帮助改善它,请这样做
先谢谢!
答案 0 :(得分:0)
也许你想要union all
而不是加入:
Select r.grantee, r.granted_role as role_or_privilege
From dba_role_privs r,
Where r.grantee = (select username from dba_users where username = 'HR');
union all
select s.grantee, s.privilege
from dba_sys_privs s
Where s.grantee = (select username from dba_users where username = 'HR');
我将where
中的逻辑与查询中的逻辑相同。但是,这对我来说更有意义:
Select r.grantee, r.granted_role as role_or_privilege
From dba_role_privs r,
Where r.grantee = 'HR';
union all
select s.grantee, s.privilege
from dba_sys_privs s
Where s.grantee = 'HR';