oralce system triggers

System event is based on oracle trigger events (such as logon, logoff and startup, shutdown) established, by using the system event triggers, provides tracking system or database change regime. The following describes the use of a system event attribute functions, methods and the establishment of various event triggers in the establishment of a system event triggers, we need to use the event attribute function, common event attributes function as follows:

ora_client_ip_addrewss // returns the IP client

ora_database_name // Returns the database name

ora_login_user // returns the user login name

ora_sysevent // Returns the name of the event triggering the trigger system

ora_des_encrypted_password // returns the user's password is the (MD5) encryption

establish login and logout trigger

In order to record the user's login and logout of the world, we can create a login and logout trigger; in order to record the user name, time, IP address, we first establish an information table:

SQL> conn system/system as sysdba;

SQL> create table log_table(username varchar2(20),logon_time date,logoff_time date,address varchar2(20));

We work together to complete the landing (logon) and exit (logoff) trigger, take a look at how to write?

 
 

create or replace trigger trigger name

after[before] lgoon[logoff]  on  dateabse

begin

// Execute the statement

end;

 

 

 

 

 

 

 

 

 

 

 

 

 

create or replace trigger tri7

after logon on database

begin

  insert into log_table(username,logon_time,address)

  values(ora_login_user,sysdate,ora_client_ip_address);

end;

 

create or replace trigger tri8

before logoff on database

begin

  insert into log_table(username,logoff_time,address)

  values(ora_login_user,sysdate,ora_client_ip_address);

end;

 

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11115653.html