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: