MySQL Flip-flop explanation

Source: Internet
Author: User

Trigger (Trigger): The supervisor of a situation, and set out some kind of operation.

Trigger creation Syntax Four elements: 1, watch location (table) 2, monitor event (Insert/update/delete)

3, Trigger Time (After/before) 4, trigger event (Insert/update/delete)

Create Trigger Triggername

After/before (3) Insert/update/delete (2) on TableName (1)

For each row

Begin

SQL statements (4)

End

*1,2,3,4 corresponds to four elements

Let's start by creating two tables:

#test_datax

Create Table Test_datax (

user_id Int (12),

User_name varchar (225),

Latesttime Timestamp

);

#uptable

Create Table Uptable (

user_id Int (12),

User_name varchar (225),

Latesttime Timestamp

);

Delimiter $

Create Trigger TG1

After update on Test_datax

For each row

Begin

Insert into uptable (user_id,user_name,latesttime) values (old.user_id,new.user_name,new.latesttime);

end$

MySQL Flip-flop explanation

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.