What is trigger?

In database, trigger is a stored procedure that may be configured to automatically execute when certain events take place. Triggers can restrict access to specific data, perform logging, or audit data modifications. Each trigger is associated with a single table and is set to fire when records are inserted into, updated in, or deleted from that table. Triggers offer database developers and administrators a tremendous degree of flexibility. They are, quite simply, stored procedures that may be configured to automatically execute when certain events take place.

The basic command which is used to create a new trigger is the CREATE TRIGGER statement. This statement is followed by the details of when the trigger should fire. Triggers may be associated with INSERT, UPDATE and DELETE events and may be used either INSTEAD OF or AFTER the specified operation. Once you've specified the trigger criteria, you supply the SQL statement that contains the trigger's payload.

There are two classes of triggers: "row triggers" or "statement triggers". Row triggers define an action for every row of a table, while statement triggers occur only once per INSERT, UPDATE, or DELETE statement. Triggers cannot be used to audit data retrieval via SELECT statements.

SQL trigger Syntax:

trigger_knowledge_base


: What is static function?
: What is stored procedure?



Tags: triggers  SQL Server   stored procedure   row triggers   statement triggers  

Readers also visit these:

Which license is best for me?
What is date type?
What is T-SQL (Transact-SQL)?
What is data backup and data recovery?
What is job manager?

Related Questions:

What is T-SQL (Transact-SQL)?
What is stored procedure?
What is alarm manager (database)?
How to remove SQL Server Comparison Expert from my local disk?