MySQL trigger Update triggers Insert failure

Source: Internet
Author: User
Tags sql error

MySQL trigger Update triggers Insert failure

To display the historical records of tables with status updates only, you need to create a trigger in the original table to write the updated content to another table at the same time.

So the test

 
-- Create a test table
Create table 'triggertest _ trigger' ('id' INT (11) not null, 'name' VARCHAR (5) null default null, primary key ('id ')) COLLATE = 'latin1 _ swedish_ci 'ENGINE = InnoDB
-- Create table 'triggletest' ('seq 'INT (11) not null, 'id' INT (11) not null, 'name' VARCHAR (5) null default null, primary key ('seq '), INDEX 'id' ('id') COLLATE = 'latin1 _ swedish_ci' ENGINE = InnoDB;
 
--- Insert into 'triggertest _ trigger' VALUES (1, 'A ');
 
-- Create the trigger drop trigger if EXISTS test1CREATE TRIGGER test1 after update on triggletest_triggleFOR each rowbegin insert into triggletest (id) values (new. id); END

Execute the trigger statement and report the following error:

/* SQL error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'create TRIGGER test1
After update on triggletest_triggle
FOR EACH ROW
BEGIN 'at line 2 */

Question to be checked

This article permanently updates the link address:

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.