我希望选择我没有特权对其执行插入操作的所有对象。我想出了一个解决方案,它使用了一个聚合函数:
select * from (
SELECT table_name, type, LISTAGG(privilege, '; ') WITHIN GROUP (ORDER BY privilege) privlist_agg
FROM ALL_TAB_PRIVS
group by table_name, type
)
where not regexp_like(privlist_agg,'INSERT')
order by type;如果没有聚合函数,我想不出如何解决这个问题,但我确信这是可能的。如何做到这一点?
发布于 2018-06-20 10:14:21
您可以用以下方法列出对象:
select table_schema, table_name, type
from all_tab_privs
group by table_schema, table_name, type
having count(case when privilege = 'INSERT' then privilege end) = 0
order by type, table_schema, table_name;如果您想在一行中查看您确实拥有的特权,那么仍然需要使用listagg();但这是一个聚合函数,而不是解析函数,无论是在原始查询中使用还是在这里如何使用它:
select table_schema, table_name, type,
listagg(privilege, '; ') within group (order by privilege) as privileges
from all_tab_privs
group by table_schema, table_name, type
having count(case when privilege = 'INSERT' then privilege end) = 0
order by type, table_schema, table_name;发布于 2018-06-20 10:12:57
一种有群的解决方案,由并具有:
select table_name, type
from (
SELECT
table_name,
type,
case when privilege = 'INSERT' then 1 else 0 end as is_insert
from ALL_TAB_PRIVS
) dt
group by table_name, type
having sum(is_insert) = 0;https://stackoverflow.com/questions/50945450
复制相似问题