InterviewSolution
Saved Bookmarks
| 1. |
Triggers in SQL |
|
Answer» SQL codes automatically executed in response to a certain event occurring in a table of a database are called triggers. There cannot be more than 1 trigger with a similar action time and event for one table. Syntax: Create Trigger Trigger_Name(Before | After) [ Insert | Update | Delete] on [Table_Name] [ for each row | for each column ] [ trigger_body ] Example: CREATE TRIGGER trigger1before INSERT ON Student FOR EACH ROW SET new.total = (new.marks/ 10) * 100; Here, we create a new Trigger called trigger1, just before we perform an INSERT operation on the Student table, we calculate the percentage of the marks for each row.
|
|