WHAT IS TRIGGERS IN SQL? AND WHAT IS THE BENIFIT?
Answers were Sorted based on User's Feedback
Answer / mallika
Triggers are the system generated events.
for example,
u have a table emp,in tat u can create a trigger which will
be activated if anyone performs any action such as insert,
update, delete on tat table.In tat trigger u can write code
which copies the updated info into another table.
we can provide security to the data by mentioning before
clause in tat trigger by which we can restrict the
modifications anyone can make to our table.
CREATE TRIGGER DelhiDel ON [Customers]
FOR DELETE
AS
IF (SELECT state FROM deleted) = ‘Delhi’
BEGIN
PRINT ‘Can not remove customers from Delhi’
PRINT ‘Transaction has been canceled’
ROOLBACK
END
| Is This Answer Correct ? | 46 Yes | 5 No |
Answer / sandeep
Triggers are also a stored procedure but it has some limits
and advantages over stored procedure.
first of all its limits. It cant accept or return values by
parameters whereas stored procedures do. It is called by
database server not by application or user.
It is generally treated as a constraint. It also make sure
the integrity of the data. We cud implement business rules
successfully by using triggers without writting a single
code in application. This is the main benifit of this
object we can change the business rule very easly from
database server when the actual business rules change that
means we dont want to edit and recompile the program soruce
code.
It will make problems in import process unless we switch
off the triggers.
There are 3 types of triggers in connection with insert,
update and delete statements
1. Before trigger
2. After Trigger
3. Instead of trigger
1. Before trigger fires before the manipulation of the data
happens by insert, update and delete statements. By using
this we cud do pre proces. ie updating other tables, pre
process of data, ..etc. After this actual manipulation
happens.
2. After triggers fires after the manipulation of the data
happens by insert, update and delete statements
3. Instead-of trigger. This trigger replaces the actual
manipulation statements. That means actual manipulation
statement wont work instead of this trigger will do the
manipulation work (statements in the trigger) by accepting
values from statement.
| Is This Answer Correct ? | 22 Yes | 2 No |
A trigger is a stored procedure that goes into effect when
you insert, delete, or update data in a table. You can use
triggers to perform a number of automatic actions, such as
cascading changes through related tables, enforcing column
restrictions, comparing the results of data modifications,
and maintaining the referential integrity of data across a
database.
| Is This Answer Correct ? | 12 Yes | 5 No |
Answer / subbarayudu
A Trigger is a block of code,fired whenever data in the underlying table is affected by any of the Data Manipulation Language (DML) statements -INSERT,UPDATE,OR DELETE.
whenever trigger fires,two special tables are created-
1.insert table 2.Delete table.
1.inserted table contains copy of all records that are insetred in the trigger table.
2.deleted table contains all records that have been deleted from trigger table.this table is used to refer old values.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / sumesh
There are mainly two type trigger
1)After trigger
2)Insted of trriger
Baisicalt its like a stroeprocedure...
| Is This Answer Correct ? | 12 Yes | 11 No |
Answer / rami reddy.k
Triggers are the system generated events.
for example,
u have a table emp,in tat u can create a trigger which will
be activated if anyone performs any action such as insert,
update, delete on tat table.In tat trigger u can write code
which copies the updated info into another table.
A trigger is a stored procedure that goes into effect when
you insert, delete, or update data in a table. You can use
triggers to perform a number of automatic actions, such as
cascading changes through related tables, enforcing column
restrictions, comparing the results of data modifications,
and maintaining the referential integrity of data across a
database.
| Is This Answer Correct ? | 2 Yes | 9 No |
Answer / kavithareddy
like as storeprocedure
it is userdefind function ther is no parameters
1)After trigger:
2)Insted of trriger
| Is This Answer Correct ? | 2 Yes | 17 No |
How can windows applications connect to sql servers via odbc?
What is the difference between clustered and a non-clustered index?
Explain filestream storage of sql server 2008?
What is self contained sub query?
Explain the architecture of ms sql reporting service?
What is the difference between indexing and hashing?
Explain the concept of recursive stored procedure.
Do you know what is blocking?
What is the difference between IN and EXISTS operators in SQL Server?
9 Answers ASD Lab, CSC, Intelligroup,
What is the difference between MVC and Teir Architecher? Plz explain with Layyered Programming example...? Thanks
What are the types of indexing?
Explain what is row_number function?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)