Oracle trigger parsing syntax

Source: Internet
Author: User

Introduction: triggerIt is a special stored procedure. Trigger execution is not triggered by a program or manually, but by an event,Oracle DatabaseIt is a database system that everyone is very familiar with. What is the syntax of Oracle triggers? The following sections will provide detailed analysis for you.

ORACLE triggers

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

Where:

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.

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.

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 table modification on weekends:

Create trigger auth_secure

Before insert or update or delete file: // triggered before update of the entire table

On auths

Begin

If (to_char (sysdate, 'dy ') = 'sun'

RAISE_APPLICATION_ERROR (-20600, 'table auths' cannot be modified on weekends ');

(RAISE_APPLICATION_ERROR is a function within the Arc. The first parameter range is-20000 ~ Between 20999 and the second

The parameter is a string with a size of 2 k. If the parameter is exceeded, the system automatically truncates it)

End if;

End

The syntax knowledge of Oracle database Triggers described above is not comprehensive. If you are interested in this knowledge, in the future, I will continue to introduce more detailed knowledge to you, hoping to help you.

Related Article

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.