What is Trigger in Orcale Database
Oracle allows you to define procedures that are implicitly executed when an DML statement (insert ,update,delete) is issued against the associated table. These procedures are called database triggers.
A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database.
For example-
create a table marks
create table marks(rollno int primary key, name varchar(20), phy int, chem int, math int);
again another create table which name is backupmarks
create table backupmarks (rollno int primary key, name varchar(20), phy int, chem int, math int);
create trigger
create trigger backuptrigger
after insert on marks for each row
begin
insert into backupmarks values(:new.rollno,:new.name,:new.phy,:new.chem,:new.math);
end;
after creating trigger you insert data in table marks
insert into marks values(1,'arvind',78,67,89);
Data is inserting only marks table but you can see automatically executed in response to certain events on a particular table backupmarks.
you can cheack results
select*from marks;
select*from backupmarks;
after running this query you got same resuls This is Trigger Concepts
0 comments:
Post a Comment