Thursday, 25 February 2016

DATABASE TRIGGERS

To create a database trigger follow the below steps:
SQL>connect as sysdba
SQL>Enter the user-name:sysdba
SQL>Password:
connected as sysdba
SQL>Create Table logintab(who varchar2(15),when timestamp);
Table created

Example: To know who are login in the database the below trigger program is used
create or replace trigger logint
after
logon
on database
begin
insert into logintab values(user,sysdba);
end;

To create a database trigger follow the below steps:
SQL>connect as sysdba
SQL>Enter the user-name:sysdba
SQL>Password:
connected as sysdba
SQL>Create Table logofftab(who varchar2(15),when timestamp);
Table created

Example: To know how much time spend the user in the database the below program is used
create or replace trigger logofft
before
logoff 
on database
begin
insert into logofftab values(user,sysdate);
end;

No comments:

Post a Comment

If you Like my blog Spread it and help friends for whom this blog is useful for their career.