Below Query find out active user in the database.
select name, CTIME as Created, PTIME as PssWdDate, EXPTIME as ExpirePasswdDate,
expiry_date as Expired_acct_date, LTIME as Locked, lock_date, account_status,
nvl(W.priv,'READ') "R/W"
from sys.USER$ u, dba_users du,
(select distinct y.username, y.priv from dba_users U,
(
select distinct dsp.grantee username,'WRITE' priv
from dba_sys_privs dsp
where (dsp.PRIVILEGE like 'ADMIN%'
or dsp.PRIVILEGE like 'ALTER%'
or dsp.PRIVILEGE like 'CREATE ANY%'
or dsp.PRIVILEGE like 'CREATE C%'
or dsp.PRIVILEGE like 'CREATE DAT%'
or dsp.PRIVILEGE like 'CREATE IND%'
or dsp.PRIVILEGE like 'CREATE JO%'
or dsp.PRIVILEGE like 'CREATE LIB%'
or dsp.PRIVILEGE like 'CREATE MATE%'
or dsp.PRIVILEGE like 'CREATE OPE%'
or dsp.PRIVILEGE like 'CREATE P%'
or dsp.PRIVILEGE like 'CREATE RO%'
or dsp.PRIVILEGE like 'CREATE SEQ%'
or dsp.PRIVILEGE like 'CREATE T%'
or dsp.PRIVILEGE like 'CREATE VIE%'
or dsp.PRIVILEGE like 'DELETE%'
or dsp.PRIVILEGE like 'DROP%'
or dsp.PRIVILEGE like 'INSERT%'
or dsp.PRIVILEGE like 'UPDATE%'
or dsp.PRIVILEGE like 'UN%'
or dsp.privilege like 'GRANT%'
or dsp.privilege like 'ANAL%'
or dsp.privilege like 'MANAGE%'
or dsp.privilege like 'FORCE%'
or dsp.privilege like '%PORT%'
or dsp.privilege like 'FLASHBACK%'
or dsp.privilege like 'EXECUTE%'
or dsp.privilege like 'AUDIT %'
or dsp.privilege like 'DE%'
or dsp.privilege like '%QUE%'
or dsp.privilege like 'UN%'
or dsp.privilege like 'BACKUP%'
or dsp.privilege like 'BECOME%'
or dsp.privilege like 'MERGE%'
or dsp.PRIVILEGE like 'LOCK%')
and dsp.PRIVILEGE not in ('CREATE SESSION','UNLIMITED TABLESPACE')
UNION ALL
select distinct dtp.grantee username,'WRITE' priv
from dba_tab_privs dtp
where dtp.privilege in ('FLASHBACK','ON COMMIT REFRESH',
'ALTER','DEQUEUE','UPDATE','DELETE','DEBUG',' QUERY REWRITE',
'USE','INSERT','INDEX','WRITE','REFERENCES','MERGE VIEW')
UNION ALL
select distinct drp.grantee username, 'WRITE' PRIV
from dba_role_privs drp
where GRANTED_ROLE in ('APPLICATION','DBA','RESOURCE')
UNION ALL
select distinct dtp.grantee usernmae, 'WRITE' Priv
from dba_tab_privs dtp
where privilege not in ('READ','SELECT','EXECUTE')
) Y
where U.username = Y.username
) W
where u.name = du.username
and du.username=w.username(+)
and account_status in ('OPEN','EXPIRED(GRACE)','LOCKED(TIMED)','EXPIRED(GRACE) '||'&'||' LOCKED(TIMED)')
order by 1
expiry_date as Expired_acct_date, LTIME as Locked, lock_date, account_status,
nvl(W.priv,'READ') "R/W"
from sys.USER$ u, dba_users du,
(select distinct y.username, y.priv from dba_users U,
(
select distinct dsp.grantee username,'WRITE' priv
from dba_sys_privs dsp
where (dsp.PRIVILEGE like 'ADMIN%'
or dsp.PRIVILEGE like 'ALTER%'
or dsp.PRIVILEGE like 'CREATE ANY%'
or dsp.PRIVILEGE like 'CREATE C%'
or dsp.PRIVILEGE like 'CREATE DAT%'
or dsp.PRIVILEGE like 'CREATE IND%'
or dsp.PRIVILEGE like 'CREATE JO%'
or dsp.PRIVILEGE like 'CREATE LIB%'
or dsp.PRIVILEGE like 'CREATE MATE%'
or dsp.PRIVILEGE like 'CREATE OPE%'
or dsp.PRIVILEGE like 'CREATE P%'
or dsp.PRIVILEGE like 'CREATE RO%'
or dsp.PRIVILEGE like 'CREATE SEQ%'
or dsp.PRIVILEGE like 'CREATE T%'
or dsp.PRIVILEGE like 'CREATE VIE%'
or dsp.PRIVILEGE like 'DELETE%'
or dsp.PRIVILEGE like 'DROP%'
or dsp.PRIVILEGE like 'INSERT%'
or dsp.PRIVILEGE like 'UPDATE%'
or dsp.PRIVILEGE like 'UN%'
or dsp.privilege like 'GRANT%'
or dsp.privilege like 'ANAL%'
or dsp.privilege like 'MANAGE%'
or dsp.privilege like 'FORCE%'
or dsp.privilege like '%PORT%'
or dsp.privilege like 'FLASHBACK%'
or dsp.privilege like 'EXECUTE%'
or dsp.privilege like 'AUDIT %'
or dsp.privilege like 'DE%'
or dsp.privilege like '%QUE%'
or dsp.privilege like 'UN%'
or dsp.privilege like 'BACKUP%'
or dsp.privilege like 'BECOME%'
or dsp.privilege like 'MERGE%'
or dsp.PRIVILEGE like 'LOCK%')
and dsp.PRIVILEGE not in ('CREATE SESSION','UNLIMITED TABLESPACE')
UNION ALL
select distinct dtp.grantee username,'WRITE' priv
from dba_tab_privs dtp
where dtp.privilege in ('FLASHBACK','ON COMMIT REFRESH',
'ALTER','DEQUEUE','UPDATE','DELETE','DEBUG',' QUERY REWRITE',
'USE','INSERT','INDEX','WRITE','REFERENCES','MERGE VIEW')
UNION ALL
select distinct drp.grantee username, 'WRITE' PRIV
from dba_role_privs drp
where GRANTED_ROLE in ('APPLICATION','DBA','RESOURCE')
UNION ALL
select distinct dtp.grantee usernmae, 'WRITE' Priv
from dba_tab_privs dtp
where privilege not in ('READ','SELECT','EXECUTE')
) Y
where U.username = Y.username
) W
where u.name = du.username
and du.username=w.username(+)
and account_status in ('OPEN','EXPIRED(GRACE)','LOCKED(TIMED)','EXPIRED(GRACE) '||'&'||' LOCKED(TIMED)')
order by 1
No comments:
Post a Comment