Home > database >  The basic knowledge of the trigger
The basic knowledge of the trigger

Time:09-20

What is the trigger
The trigger (trigger) is a kind of database objects, is also a special stored procedure, trigger based on a table is created, but can be operated for more than one table,

The trigger what was so special about
Trigger the advantages as follows:
Automatically activated
Simplify the code at the front desk
Complex integrity
Good safety
Don't accept parameters

Up sqlplus system/system
The trigger syntax:
The create (or replace) trigger time trigger events trigger flip-flop name
On the table name
[for each row]
The begin
Pl/SQL statement
end;

Among them:
The trigger name: the name of the trigger object, because the trigger is database automatically, so the name is just a name, no real purpose,
Indicate the trigger triggering time: when to perform and the value seek:
Said before: in a database trigger execution before action;
After: said in a database trigger execution after action,
Trigger: specify which database action will trigger the trigger:
Insert: database insert triggers the trigger;
Update: database modifications will trigger the trigger;
Delete: delete database triggers the trigger,
Table name: database trigger table,
For each row, each row of table trigger execution time, if you don't have this option, only for the whole table execution time,
Example:
The create or replace the trigger tr1
Before the delete
On the student for each row
The begin
The delete from student
Where sno=: old. Sno;
The end;
/

CodePudding user response:

Building Lord timely summary, praise a!

PS: in the blog better, post maybe one day I can't find it,
  • Related