Which is better in performance - CONSTRAINT or TRIGGER over
a column which restricts say an input of particular value
in a column of a table?
Answers were Sorted based on User's Feedback
Answer / jerry joseph
Restricting the input using CONSTRAINT will have better
performance but there is a limit to the types of constraints
which we can provide..
With TRIGGERS you have more flexibility and provide a more
variety restrictions to the input.. for example you can
prevent a normal delete and make it a soft delete by setting
an IsDeleted flag using trigger.. we cant have that kind of
flexibility using Constraints..
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / monal
Constraints gets evaluated before statement can be either
inserted or deleted or updated. While trigger executes
after or at the same time statement is executing. So if you
have to roll back transactio because transaction not
meeting condition there is no overhead when you are using
constraint ,but if you have to roll back transaction and
you have a trigger on that table or column either 1
transaction goes through before rolling back. So basically
trigger consumes more resources.
| Is This Answer Correct ? | 7 Yes | 3 No |
Answer / guest
Constraint is better in terms of performance for same
operation. Why??
| Is This Answer Correct ? | 0 Yes | 3 No |
What is the difference between the application object and session object?
What is DAC? what is the use of it?
One table Test with single column. These are the values in the table a b c d e f g h I need a query (without using any variable) with output as - a b c d f f g h
Why do we use non clustered index?
What is the Control Flow in SSIS
Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do you troubleshoot?
How to sort the query output with order by clauses in ms sql server?
What are the advantages of passing name-value pairs as parameters?
Which is best Subquery (or) joins in sql server? explain why
What is difference between delete and truncate commands?
application server is slow what may be the problem
How to call a function from a stored procedure in SQL Server ?
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)