Today's work requires that you want to implement a history of the tables that will only update the status, so consider setting up triggers in the original table and writing the updated content to another table
So I tested it.
--Establish a test table create table ' Triggletest_triggle ' (
' id ' INT () not NULL,
' name ' VARCHAR (5) null DEFAULT NULL,
PRIMARY KEY (' id ')
)
collate= ' latin1_swedish_ci '
engine=innodb
-Set the target table
create TABLE ' Triggletest ' (
' seq ' int (one) not NULL,
' id ' int (one) not null,
' name ' VARCHAR (5) null DEFAULT null,
PRI MARY KEY (' seq '),
INDEX ' id ' (' id ')
)
collate= ' latin1_swedish_ci '
engine=innodb;
---write test data
INSERT into ' Triggletest_triggle ' VALUES (1, ' A ');
--Create a trigger
DROP TRIGGER if EXISTS test1
create TRIGGER test1 after
UPDATE on Triggletest_triggle
for Each ROW
BEGIN
inserts into triggletest (ID) values (new.id);
Execute the trigger statement, an error, the error content is as follows:
/* SQL error (1064): You have a 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 in triggletest_triggle for each
ROW
BEGIN ' in line 2 */
---The final implementation code
DROP TRIGGER if EXISTS tes T1;
CREATE TRIGGER test1 after UPDATE in test.triggletest_triggle for each ROW
BEGIN
INSERT into Triggletest (id,name) Values (new.id,new.name);
Analysis, due to the Access tool hedisql, resulting in the failure to create a trigger, the same statement, executed in the Hedisql, error, use shell invoke MySQL, direct execution program, success.