Do you know about Oracle triggers?

Source: Internet
Author: User

I like Oracle very much. I also like to sum up the experience and lessons of Oracle triggers in my work. Let's talk about this in detail. There are two types of Oracle triggers: after and before. The difference is that each commit transaction is triggered once and each row of data is updated once. Pay attention to this when using it to avoid failure to achieve the goal.

The syntax for Oracle to generate database triggers is:
Create [or replace] trigger name trigger time trigger event
On Table Name
[For each row]
Pl/SQL statements

Oracle trigger name: name of the trigger object. Because the trigger is automatically executed by the database, the name is only a name and has no substantive purpose.

Oracle trigger time: specifies when the trigger is executed. This value is optional:
Before --- indicates that the trigger is executed before the database action;
After --- indicates that the logpilot executes the database action.

Oracle trigger event: Specifies which database actions will trigger this trigger:
Insert: This trigger is triggered when the database is inserted;
Update: This trigger is triggered when the database is modified;
Delete: This trigger is triggered when a database is deleted.

Table Name: The table where the database trigger is located.
For each row: the trigger for each row of the table is executed once. If this option is not available, the entire table is executed only once.

For example, the following trigger is triggered before the table auths is updated to prevent

Weekend table modification:

 
 
  1. Create trigger auth_secure
  2. Before insert or update or delete
  3. // Triggered before update of the entire table
  4. On auths
  5. Begin
  6. If (to_char (sysdate, 'dy ') = 'sun'
  7. RAISE_APPLICATION_ERROR (-20600, 'table auths' cannot be modified on weekends ');
  8. End if;
  9. End
  1. Oracle object privileges
  2. Oracle System privileges
  3. Common Oracle password verification
  4. Brief Discussion on Oracle media recovery
  5. Completely kill the Oracle deadlock Process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.