请给些意见吗!!!

请给些意见吗!!!

CREATE TABLE log (
log_user VARCHAR2(30),
database_name VARCHAR2(30),
event_name VARCHAR2(30),
log_time DATE);



CREATE OR REPLACE TRIGGER user_logon
AFTER LOGON ON DATABASE
BEGIN
INSERT INTO log (log_user,database_name,event_name,log_time)
VALUES(sys.login_user,sys.database_name,sys.sysevent,SYSDATE);
END;
/

请给一些意见!OK?      
应该是可以实现的。
你是否想记录登陆数据库的状态和次数?ORACLE有现成的脚本,去metalink上找,记录的更为详细。      
/* copyright metalink of oracle */

create table user_login_logout_info

(

event varchar2(10),

sid number,

serial# number,

timestamp date,

username varchar2(30),

osuserid varchar2(30),

machinename varchar2(64)

)

/

2. Create LOGON trigger at DATABASE level.

create or replace trigger logonauditing after logon on database

declare

machinename varchar2(64);

osuserid varchar2(30);

v_sid number(4);

v_serial number(4);

cursor c1 is select sid, serial#, osuser, machine

from v$session

where username = sys_context('USERENV','CURRENT_USER');

begin

open c1;

fetch c1 into v_sid, v_serial, osuserid, machinename;

insert into user_login_logout_info values( 'LOGON', v_sid,

v_serial, sysdate, user, osuserid, machinename );

close c1;

end;

/

3. Create LOGOFF trigger

create or replace trigger logoffauditing before logoff on database

declare

machinename varchar2(64);

osuserid varchar2(30);

v_sid number(4);

v_serial number(4);

cursor c1 is select sid, serial#, osuser, machine

from v$session

where username = sys_context('USERENV','CURRENT_USER');

begin

open c1;

fetch c1 into v_sid, v_serial, osuserid, machinename;

insert into user_login_logout_info values( 'LOGOFF', v_sid,

v_serial, sysdate, user, osuserid, machinename );

close c1;

end;

/

Check the result:

~~~~~~~~~~~~~~~~~

select event, sid, serial#, username, osuserid,

to_char(timestamp,'dd-mon-yyyy hh24:mi:ss') as TIMESTAMP, machinename

from user_login_logout_info;      
谢谢!!!