TRIGGERS are stored program/ special stored procedure that execute automatically in response to database object, database, and server events.
For example, a trigger can be invoked when a row is deleted or inserted.
Types of Triggers:
- DDL TRIGGERS: which fires/ triggers in response to CREATE, ALTER, and DROP statements.
- DML TRIGGERS: which are invoked automatically in response to INSERT, UPDATE, and DELETE commands.
- LOGON TRIGGERS: Invokes only in responses to LOGON events.
SYNTAX:
CREATE TRIGGER:
CREATE
TRIGGER [SCHEMANAME].TRIGGER_NAME
ON
TABLE_NAME AFTER
{ [INSERT],
[UPDATE],
[DELETE] } AS { //YOUR
CODE }
|
DROP TRIGGER
DROP TRIGGER [IF EXISTS] [SCHEMA_NAME].TRIGGER_NAME |
DROP TRIGGER statement drops one or more triggers from the database.
0 Comments