简体   繁体   中英

MySQL error in trigger syntax

I'm trying to create a trigger to allow only one line per table. This database will be used by more than one software so I would like this automation to be done by the database.

Before the insert, the database should clean the previous register, plus the foreign tables.

At the moment I'm trying to clean the current table, but I'm having syntax errors

在此处输入图片说明

EDIT:

Adding a semicolon on DELETE FROM sensor; 在此处输入图片说明

Try removing the begin/end:

CREATE TRIGGER before_insert_sensor BEFORE INSERT ON `sensor`
FOR EACH ROW
DELETE FROM sensor;

You might encounter issues trying to delete during the insert, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM