?????????μ???????????????????:
???????????μ??????:

 

create table login_log -- ???????????
(
session_id int not null?? -- sessionid
login_on_time date?? -- ???????
login_off_time date?? -- ??????
user_in_db varchar2(30)?? -- ?????db user
machine varchar2(20)?? -- ??????
ip_address varchar2(20)?? -- ip???
run_program varchar2(20) -- ??γ??????
);
create table allow_user -- ?????????
(
ip_address varchar2(20)?? -- ip???
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'); --???SESSION
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'); --???SESSION
exception
when others then
null;
END;