Differences between MySQL trigger and oracle trigger

Source: Internet
Author: User
MySQL trigger is only activated by statement. You cannot write two triggers to the same event of the same table. The same event refers to the trigger _

MySQL trigger is only activated by statement. You cannot write two triggers to the same event of the same table. The same event refers to the trigger _

The MySQL trigger is only activated by statement and cannot write two triggers for the same event of the same table. The same event refers to trigger_time + trigger_event in the create trigger. trigger will not be activated because of changes to some tables. The changes to these tables are modified using APIs that do not send statements to mysql server.

1. mysql can only trigger each row once, while Oracle can trigger the whole table of each row once.
2. mysql can only be a row activation trigger for tables, but oracle can trigger columns.

Definitions of triggers in oracle:

CREATE
[Or replace] trigger_name trigger_time trigger_event of column
ON tbl_name referencing old as old_value
New as new_value
For each row trigger_stmt

Mysql trigger Definition Statement:
CREATE
[DEFINER = {user | CURRENT_USER}]
TRIGGER trigger_name trigger_time trigger_event
ON tbl_name for each row trigger_stmt

A simple test is as follows:

Mysql> delimiter |
Mysql> create trigger test_a before insert on
-> FOR EACH ROW BEGIN
-> Insert into abc SET id = NEW. id;
->
-> END;
-> |
Query OK, 0 rows affected (0.00 sec)

Mysql> delimiter;
Mysql>
Mysql>
Mysql> delimiter |
Mysql> create trigger test_ B BEFORE INSERT ON
-> FOR EACH ROW BEGIN
-> Insert into abc SET name = NEW. name;
->
-> END;
-> |
ERROR 1235 (42000): This version of MySQL doesn't yet support 'Multiple triggers with the same action time and event for one table'
Mysql> delimiter;
Mysql>
Mysql>
Mysql> delimiter |
Mysql> create trigger test_ B AFTER INSERT ON
-> FOR EACH ROW BEGIN
-> Insert into abc SET name = NEW. name;
->
-> END;
-> |
Query OK, 0 rows affected (0.00 sec)

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.