break on usuario skip 1
with u as (
select distinct grantee as usuario, privilege as priv from DBA_SYS_PRIVS
where grantee like 'P#_%' escape '#' and privilege not in ('CREATE SESSION')
union
select distinct grantee as usuario, PRIVILEGE||' on ' || owner || '.' ||table_name as priv from DBA_TAB_PRIVS
where grantee like 'P#_%' escape '#'
union
select distinct grantee as usuario, granted_role as priv from DBA_ROLE_PRIVS
where grantee like 'P#_%' escape '#'
and granted_role not in ('DBA', 'CONNECT', 'ROLCOPAGCONSULTA', 'ROLSICODCONSULTAGESTORES')
and granted_role not like 'WF#_%' escape '#'
and granted_role not like '%CECIN%'
)
select 'REVOKE '||priv||' from '||usuario||';' from u
where usuario not in ('P_7777','SYS', 'WKSYS', 'CTXSYS', 'SYSMAN', 'SYSTEM', 'USR_DBA','P_1978');
with u as (
select distinct grantee as usuario from DBA_SYS_PRIVS
where grantee like 'P#_%' escape '#' and privilege not in ('CREATE SESSION', 'CONNECT')
union
select distinct grantee as usuario from DBA_TAB_PRIVS
where grantee like 'P#_%' escape '#'
union
select distinct grantee as usuario from DBA_ROLE_PRIVS
where grantee like 'P#_%' escape '#'
and granted_role not in ('DBA', 'CONNECT')
and granted_role not like 'WF#_%' escape '#'
and granted_role not like '%CECIN%'
)
select DISTINCT usuario from u
where usuario not in ('P_7777','SYS', 'WKSYS', 'CTXSYS', 'SYSMAN', 'SYSTEM', 'USR_DBA');