If you ever require to audit the login and logout of the user, the below query will work in Oracle 10g and 11g as well.
alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
SELECT sessionid,
MIN(TIMESTAMP)login_time,
MAX(TIMESTAMP) logout_time
FROM dba_audit_trail
WHERE username=UPPER('&user')
GROUP BY sessionid
ORDER BY 1;
Output:
SESSIONID LOGIN_TIME LOGOUT_TIME
---------- -------------------- --------------------
40031 08-NOV-2012 11:23:32 08-NOV-2012 11:44:45
160023 23-NOV-2012 13:40:07 23-NOV-2012 15:42:23
170023 26-NOV-2012 11:43:28 26-NOV-2012 13:55:00
170024 26-NOV-2012 11:44:23 26-NOV-2012 11:44:23
170025 26-NOV-2012 11:44:31 26-NOV-2012 13:55:40
170053 26-NOV-2012 14:57:48 26-NOV-2012 14:57:58
170054 26-NOV-2012 14:58:16 26-NOV-2012 14:58:22
170055 26-NOV-2012 14:58:24 26-NOV-2012 17:12:45
170081 26-NOV-2012 18:00:20 26-NOV-2012 18:54:22
180299 27-NOV-2012 14:43:07 27-NOV-2012 17:34:38
190025 27-NOV-2012 22:44:27 27-NOV-2012 22:55:20
200330 28-NOV-2012 18:08:45 28-NOV-2012 18:41:57
210029 30-NOV-2012 22:28:31 30-NOV-2012 23:43:16
310660 14-DEC-2012 17:48:28 14-DEC-2012 18:16:41
340999 20-DEC-2012 18:41:17 20-DEC-2012 19:39:49
370772 27-DEC-2012 10:45:22 27-DEC-2012 10:45:22
370773 27-DEC-2012 10:45:26 27-DEC-2012 11:14:15
381646 29-DEC-2012 00:24:20 29-DEC-2012 00:24:20
18 rows selected.
Hope it is useful for someone.
alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
SELECT sessionid,
MIN(TIMESTAMP)login_time,
MAX(TIMESTAMP) logout_time
FROM dba_audit_trail
WHERE username=UPPER('&user')
GROUP BY sessionid
ORDER BY 1;
Output:
SESSIONID LOGIN_TIME LOGOUT_TIME
---------- -------------------- --------------------
40031 08-NOV-2012 11:23:32 08-NOV-2012 11:44:45
160023 23-NOV-2012 13:40:07 23-NOV-2012 15:42:23
170023 26-NOV-2012 11:43:28 26-NOV-2012 13:55:00
170024 26-NOV-2012 11:44:23 26-NOV-2012 11:44:23
170025 26-NOV-2012 11:44:31 26-NOV-2012 13:55:40
170053 26-NOV-2012 14:57:48 26-NOV-2012 14:57:58
170054 26-NOV-2012 14:58:16 26-NOV-2012 14:58:22
170055 26-NOV-2012 14:58:24 26-NOV-2012 17:12:45
170081 26-NOV-2012 18:00:20 26-NOV-2012 18:54:22
180299 27-NOV-2012 14:43:07 27-NOV-2012 17:34:38
190025 27-NOV-2012 22:44:27 27-NOV-2012 22:55:20
200330 28-NOV-2012 18:08:45 28-NOV-2012 18:41:57
210029 30-NOV-2012 22:28:31 30-NOV-2012 23:43:16
310660 14-DEC-2012 17:48:28 14-DEC-2012 18:16:41
340999 20-DEC-2012 18:41:17 20-DEC-2012 19:39:49
370772 27-DEC-2012 10:45:22 27-DEC-2012 10:45:22
370773 27-DEC-2012 10:45:26 27-DEC-2012 11:14:15
381646 29-DEC-2012 00:24:20 29-DEC-2012 00:24:20
18 rows selected.
Hope it is useful for someone.
No comments:
Post a Comment