[Oracle] ORACLE trigger syntax

Source: Internet
Author: User

ORACLE trigger syntax

There are two types of triggers: after and before,

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

So 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 you do not have this

To the entire table.

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

Weekend table modification:

Create trigger auth_secure

Before insert or update or delete // triggered before update of the whole table

On auths

Begin

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

Raise_application_error (-20600, 'table auths' cannot be modified on weekends); -- the trigger can only throw an exception to implement rollback.

End if;

End

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.