创建一个登陆信息登记表
create table login_log
(
session_id int not null,
login_on_time date,
login_off_time date,
user_in_db varchar2(30),
machine varchar2(20),
run_program varchar2(20)
);
create table allow_user
(
ip_address varchar2(20),
login_user_name nvarchar2(20)
);
创建两个触发器:
create or replace trigger login_on_info
after logon on database
Begin
insert into login_log(session_id,login_on_time,login_off_time,user_in_db,machine,ip_address,run_program)
select AUDSID,sysdate,null,sys.login_user,machine,SYS_CONTEXT(’USERENV’,'IP_ADDRESS’),program
from v$session 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;
阅读(2357) | 评论(0) | 转发(0) |