What  are  the  differences  between  Database  Trigger and Integrity constraints ?

A declarative integrity constraint is a statement about the database that is always true. A constraint applies to existing data in the table and any statement that manipulates the table. A  trigger  does  not  apply  to  data  loaded before the definition of the trigger,  therefore,  it does not guarantee all data in a table conforms to the rules established by an associated trigger. A trigger can be used to enforce transitional constraints where as a declarative integrity constraint cannot be used.

Showing Answers 1 - 4 of 4 Answers

samiksc

  • Jan 19th, 2006
 

A trigger is a piece of code which gets automatically executed upon occurrence of an event. It may not be meant for enforcing integrity. For example you may want to save the user info as soon as he makes an entry into a particular table. This will be achieved by means of a trigger.

An integrity constraint defines basic rules for a table's columns. It will always be enforced, for all data which was there in the table before the rule was added and to the new data which will be added to the table in future.

  Was this answer useful?  Yes

Chankey007

  • Oct 25th, 2010
 

An integrity constraint defines a business rule for a table column which automatically takes care by Oracle internally. Intefrity Constraints are NOT NULL, UNIQUE, CHECK, PRIMARY KEY, FOREIGN KEY.


 A database trigger is a procedure written in PL/SQL and Will run implicitly when data is modified or when some user or system actions occur. Triggers are database objects which gets stored in database and get fires when INSERT or UPDATE statement attempts to violate the integrity rule, Oracle must roll back the statement and return an error if trigger exists.Database triggers are BEFOR/AFTER/{BEFORE|AFTER} {row|statement} etc.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions