Home » SQL & PL/SQL » SQL & PL/SQL » Constraint and Trigger (oracle9i)
Constraint and Trigger [message #438654] Mon, 11 January 2010 07:45 Go to next message
prakashaa
Messages: 31
Registered: November 2009
Location: Bangalore
Member
Hi all plese help me on the following Question

What is the difference between Constraint and Trigger,
which one is better to create on a table and which one will execute first.

Please help me with scenario.

Thanks in advance.

Re: Constraint and Trigger [message #438657 is a reply to message #438654] Mon, 11 January 2010 08:01 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
They overlap a bit in the functionality that they provide, but they are very diferent creatures.

A CONSTRAINT is a restriction on the data that is built into the table - all rows in a table can be guaranteed to meet all the constraints present on a table.
Constraints cannot alter data - they can only raise an exception if the data is incorrect.

The most common uses of constraints are to enforce Primary Keys, foreign Key relationships between tables, uniqueness of columns, and to check that data in columns meets certain requirements.

You can read about Constraints Here

A trigger is a piece of pl/sql that is executed when certain conditions are met.
They are most frequently created to run either before or after one or more types of DML statements (insert, update, delete), either once for each row, or once for the statement.
Triggers can modify data in many ways.

You can read about triggers Here

Previous Topic: hard parsing
Next Topic: create trigger problem
Goto Forum:
  


Current Time: Sun Dec 11 06:29:41 CST 2016

Total time taken to generate the page: 0.12452 seconds