What is the difference between constraints and triggers?
Answers were Sorted based on User's Feedback
Answer / rishi kumar
Constraint is used for column
Trigger is used for table
| Is This Answer Correct ? | 23 Yes | 7 No |
Answer / sairam
Both will be used to implement business rules.
Constraints will do memory location to table comparision.
where as triggers will do table to table comparision.
for this triggers will use magic tables(inserted,deleted).
In the order of precedence first Constraints next Triggers,
But performance wise triggers will give best performance
because table to table comparision is faster than memeory
location to table comparision.
| Is This Answer Correct ? | 17 Yes | 8 No |
Answer / amit upadhyay
DIFFRENCE BETWEEN CONSTRAINTS AND TRIGERS
CONSTRAINTS :- IS USED FOR ENFORCING THE DATA INTEGRITY.
TRIGGER :- SQL SERVER AUTOMATICALLY FIRED TRIGGER
WHENEVER WE DO DML OPERATION.THIS IS ALSO
USED FOR ENFORCING THE DATA INTEGRITY.
WHENEVER TRIGGER IS FIRED TWO MAGIC TABLE
ARE CREATED.ONE IS INSETRTED AND SECOND
IS DELETED.
| Is This Answer Correct ? | 9 Yes | 3 No |
Answer / harshad more
Constraints are great at maintaining database integrity for
database fields and relationships between database tables.
Triggers are great for checking past vs. current values and
making decisions based on that data.
In my experience, it is usually much more favorable to use
constraints when possible and leave the trickier business
and auditing logic for use in triggers.
| Is This Answer Correct ? | 7 Yes | 2 No |
Answer / nageswarao
Constraints are predefined business rules in which all the
organisations follow this constraints without any
modification.
trigger is a user defined business rule for which user is
responasible for logic for business rule
| Is This Answer Correct ? | 9 Yes | 6 No |
Answer / a.ganesh
constraints is predefined onc, but trigger can be defined
by user
| Is This Answer Correct ? | 4 Yes | 2 No |
I dont' think Triggers are performanc wise more superior to
constraints. Constraints are isolated to table level
whereas triggers are flexible to do the validation on any
number of tables.
| Is This Answer Correct ? | 6 Yes | 5 No |
Answer / sairam singh
Both will be used to implement business rules.
Constraints will do memory location to table comparision.
where as triggers will do table to table comparision.
for this triggers will use magic tables(inserted,deleted).
In the order of precedence first Constraints next Triggers,
But performance wise triggers will give best performance
because table to table comparision is faster than memeory
location to table comparision.
| Is This Answer Correct ? | 4 Yes | 3 No |
Answer / malini paul
1.Constraint is a statement about a database that is always
true.Whereas triggers constrain what a transaction can do.
2.Constrain applies to existing data in the table and any
statement that manipulates the table.Whereas Trigger does
not apply to data loaded before the trigger was created.
| Is This Answer Correct ? | 3 Yes | 3 No |
What is the difference between ddl,dml and dcl commands?
0 Answers BirlaSoft, Verifone,
What program is used to store the data source file?
What is repeatable read?
What are the different types of replication you can set up in sql server?
How to add additional conditions in SQL?
How to create function without parameter in sql server?
what is the sql equivaent of the dataset relation object ?
Is the log file is a part of file group?
1.what is the diff between nolock optimizer and read uncommitted isolation? 2.what is the diff between revoke and deny? 3.what is percieved down time? 4.whether password protection are required for backups?if yes why?if no why? 5.what is fill factor? 6.what is cost analysis? 7.what is mean by piece meal restore? 8.what is 'rowguidcol'? 9.impersonate permission? 10.what is selectivity?
What is the use of builtinadministrators group in sql server? : sql server security
Is sql server is free?
Where do we use trace frag?
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)