SQL
What is trigger in SQL
A trigger is an advanced SQL concept. Triggers are user-defined SQL command that is invoked automatically in response to an event such as insert, delete or update.
Trigger Syntax:
create trigger
Trigger_name trigger_time
trigger event
on table_name for each row
begin
—
end;
*Trigger time: before or after,
*Trigger event: insert delete or update
Example:
I will create a table of three columns name, age, enrollment date.
The trigger here consists of assigning 0 to age with a negative value.
Result without trigger:
Result with trigger: