我为我的数据库写了触发器。
CREATE TRIGGER executor_type_check BEFORE INSERT ON executors
FOR EACH ROW
BEGIN
IF NEW.points <> 100
SET NEW.points = 0;
END IF;
END
导入sql文件时出现以下错误
You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SET NEW.points = 0' at line 5
我的.sql文件具有以下结构:
没有触发器,不会显示错误。
答案 0 :(得分:0)
根据您问题下面的Comments
。
THEN
声明之后您遗失了IF
。还需要添加DELIMITER
。
试试这个:
DELIMITER $$
CREATE TRIGGER executor_type_check BEFORE INSERT ON executors
FOR EACH ROW
BEGIN
IF NEW.points <> 100
THEN
SET NEW.points = 0;
END IF;
END;$$
DELIMITER ;