Trigger
The main function of the trigger is that it can realize the complex referential integrity and data consistency which cannot be guaranteed by the primary key and foreign key, plus the function of enforcing the constraint and cascade running.
--triggers are essentially a stored procedure,
--Just not call execution through exec,
--instead of triggering execution by adding or removing changes to the database
Select *from Student
Select *from Score
Alter TRIGGER Tr_student_delete
On student
For delete
--triggers are triggered when deleted, replacing the original operation with the action in the trigger
As
--delete from score where sno=108
INSERT into student values (' 108 ', ' Peng Zeng ', ' Male ', ' 1977-09-01 ', ' 95033 ')
--delete from student where sno=108
Go
Delete from Student where sno=108
ALTER TABLE teacher Disable trigger all--Disable all triggers for the datasheet
ALTER TABLE teacher enable trigger all--all triggers on the datasheet
Inserted temporary table holds any new information after the change
Deleted temporary table holds the deletion information of the last article
After (for) trigger (triggered later)
Instead OF triggers (previously triggered) the main advantage is that non-modifiable views can support modifications.
Database (10)