Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

trigger

Posted on 2016-07-28
5
65 Views
Last Modified: 2016-07-28
what is the use of trigger in oracle database. where exactly it is used which occassions.
0
Comment
Question by:anishtv
5 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 41733437
What type of trigger?

There are system level and table level.  There are also "instead of" triggers for DML on views.

The online documentation is the best place to start:
http://docs.oracle.com/database/121/LNPLS/triggers.htm#LNPLS020
0
 
LVL 32

Expert Comment

by:awking00
ID: 41733439
Too many uses to enumerate. It's used wherever the occasion calls for it. Frequently it is used in conjunction with a sequence to generate an identity.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 41733474
triggers are, in my experience, used when users/applications have direct access to an object  but you want to maintain some level of consistent functionality.

For example - someone writes an insert statement to create a new row in a table.  You can use a trigger to ensure some columns are populated a certain way or others are not populated.  It can be as simple as forcing capitalization, or trimming white space.
or more sophisticated key generation/lookup or complicated calculations.

Similarly, if someone else writes an update or a delete, maybe you want to capture that action and write something else, or possibly block the action if the update or delete is invalid for some reason.


If you have a procedural api instead, that is, nobody can write sql directly against the object, but can only access it through procedures, then triggers are not necessary and are generally considered bad practice.
0
 
LVL 15

Expert Comment

by:Devinder Singh Virdi
ID: 41733488
Another important thing about trigger is that it slows down DML because for every DML Oracle has to invoke and execute Trigger code.
0
 

Author Closing Comment

by:anishtv
ID: 41733949
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question