Triggers are special stored procedures that run in the database, but cannot invoke triggers by calling names, and triggers are automatically responded to.
a trigger is also a transaction, where an error is rolled back .
Triggers are divided into DDL triggers and DML triggers
1: Different Trigger objects:
A DML trigger belongs to a table or view; a DDL trigger belongs to a database or server.
2: Different trigger modes:
DML triggers operate on Insert, Update, and Delete statements and can be used as after triggers and Instead of triggers.
DDL triggers perform operations on Create, Alter, Drop, and other DDL statements, as well as stored procedures that perform DDL-type operations, only as after triggers and not instead OF triggers.
3: System response mechanism is different:
DML triggers get actions that trigger events by accessing dynamic tables inserted and deleted.
DDL triggers capture triggered events that activate DDL triggers and subsequent change information caused by triggers by using the EVENTDATA function.
4: Different trigger times:
The DML trigger responds with an Insert,update,delete event that executes automatically.
DDL triggers respond to two types of events: The event that begins with Create,alter,drop, and the Grant,deny,revoke event for the Data Control language.
After trigger mode with instead OF trigger mode
After triggers are fired after processing the trigger action (Insert, Update, or Delete), Instead of triggers, and constraints. Instead of is to be fired before processing the constraint in place of the triggering action.
SQL Server triggers simple learning notes