Saturday, May 31, 2014

find user last login

Often times IT security would want to find out which DB users have been inactive for the last 6 months.  Below query will find out.

Note: You need Query History DB enabled to do this.

select username from _v_user
minus
select distinct sessionusername
from (
select sessionusername, to_char(connecttime,'MMYYYY') as connectime, count(*)
from "$hist_session_prolog_1"
group by sessionusername, to_char(connecttime,'MMYYYY')
having to_char(connecttime,'MMYYYY') in (122013,012014,022014,032014,042014,05014)) a

No comments:

Post a Comment