Mysql trigger new old

Source: Internet
Author: User

Mysql trigger new old details mysql trigger new old: www.2cto.com "NEW. column_name "or" OLD. column_name ". in this way, it is technically processed (NEW | OLD. column_name) the New and Old column names belong to the created transition variable ("transition variables "). For INSERT statements, only NEW statements are valid; For DELETE statements, only OLD statements are valid; and UPDATE statements can be used together with NEW and OLD statements. The following is an example of using both NEW and OLD in UPDATE. Create trigger tr1 before update on t22 for each row begin set @ old = OLD. s1; SET @ new = NEW. s1; END; if the value of column s1 in Table t21 is 55, the value of @ old is 55 after "UPDATE t21 SET s1 = s1 + 1" is executed, www.2cto.com and @ new will change to 56. Trigger execution interval: The for each row clause notifies the trigger to execute an action on every ROW instead of the entire table. Column value increment: create table a (id int primary key auto_increment, # Set to auto increment name varchar (10); set the initial value to 1000: alter table tablename AUTO_INCREMENT = 1000;

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.