GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Oracle  >  Programmatic Constructs

 Print  |  
Question:  
What  are  the  differences  between  Database  Trigger and Integrity constraints ?

Answer:
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.


January 01, 2006 04:27:47 #1
 samiksc   Member Since: October 2005    Total Comments: 231 

RE: What  are  the  differen...
 

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.

     

 

Back To Question