1
V$SESSION
보기에는 현재 로그인 한 사용자 목록이 포함되어 있지만 로그 테이블이나 다른 곳에 저장되어 있습니까?세션이 어딘가에 저장되어 있습니까?
나는 기본적으로 (예를 들어) PL/SQL
V$SESSION
보기에는 현재 로그인 한 사용자 목록이 포함되어 있지만 로그 테이블이나 다른 곳에 저장되어 있습니까?세션이 어딘가에 저장되어 있습니까?
나는 기본적으로 (예를 들어) PL/SQL
으로 로그인 한 경우 오라클은 이러한 정보를 저장하지 않는 것을 어제 사용자 목록을 얻을 필요가있다. 몇 가지 옵션이 있습니다.
SQL> show parameter audit_trail
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_trail string DB, EXTENDED
SQL> select sessionid
2 , userid
3 , decode(action#, 100, 'logon', 101, 'logoff')
4 from sys.aud$
5 where action# in (100, 101);
no rows selected
SQL> audit connect;
Audit succeeded.
SQL> conn hr/hr
Connected.
SQL> select sessionid
2 , userid
3 , decode(action#, 100, 'logon', 101, 'logoff')
4 from sys.aud$
5 where action# in (100, 101);
SESSIONID USERID DECODE
---------- ------------------------------ ------
1000712 HR logon
SQL> conn hr/hr
Connected.
SQL> select sessionid
2 , userid
3 , decode(action#, 100, 'logon', 101, 'logoff')
4 from sys.aud$
5 where action# in (100, 101);
SESSIONID USERID DECODE
---------- ------------------------------ ------
1000712 HR logon
1000712 HR logoff
1000713 HR logon
예 :
SQL> create table Logon_history(
2 sessionid number,
3 userid varchar2(31),
4 logon_date timestamp,
5 logoff_date timestamp
6 )
7 ;
Table created
SQL> create or replace trigger TR_LOGON_STAT after logon
2 on database
3 begin
4 insert into Logon_history(Sessionid, Userid, Logon_Date, Logoff_Date)
5 values(sys_context('userenv', 'sessionid'), user, systimestamp, null);
6 end;
7/
Trigger created
SQL> create or replace trigger TR_LOGOFF_STAT before logoff
2 on database
3 begin
4 insert into Logon_history(Sessionid, Userid, Logon_Date, Logoff_Date)
5 values(sys_context('userenv', 'sessionid'), user, null,systimestamp);
6 end;
7/
Trigger created
SQL> select sessionid
2 , userid
3 , logon_date
4 , logoff_date
5 from Logon_history
6 ;
no rows selected
SQL> conn hr/hr
Connected.
SQL> select sessionid
2 , userid
3 , logon_date
4 , logoff_date
5 from Logon_history
6 ;
Sessionid Userid Logon_Date Logoff_Date
--------------------------------------------------------------------------------
2490674 HR 01-NOV-12 11.46.23.421000 PM
2490672 HR 01-NOV-12 11.46.23.343000 PM
여기서 예