日期:2014-05-16 浏览次数:20471 次
create table login_log ( session_id int not null, SID INT, login_on_time date, login_off_time date, user_in_db varchar2(100), machine varchar2(100), os_user varchar2(100), ip_address varchar2(20), run_program varchar2(100) );
create or replace trigger login_on_info after logon on database Begin insert into login_log(session_id,SID,login_on_time,login_off_time,user_in_db,machine,os_user,ip_address,run_program) select AUDSID,SID,sysdate,null,sys.login_user,machine,a.OSUSER,SYS_CONTEXT('USERENV','IP_ADDRESS'),NVL(program,MODULE) from v$session a where AUDSID = USERENV('SESSIONID'); END;
create or replace trigger login_off_info before logoff on database Begin update login_log set login_off_time = sysdate where session_id = USERENV('SESSIONID'); exception when others then null; END;
SELECT * FROM login_log;
Thu Apr 7 14:58:00 2011 Errors in file /opt/oracle/app/oracle/admin/bks/bdump/bks_ora_7456.trc: ORA-04098: trigger 'SYS.LOGIN_ON_INFO' is invalid and failed re-validation