1. 程式人生 > >ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that correspond

ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that correspond

報錯:

Warning: Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 2: 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 '--tri_afterinsert_on_plan
DROP TRIGGER IF EXISTS tri_afterinsert_on_plan' at line 1

原因:沒按照觸發器的語法編寫,編寫有誤。
解決:
錯誤,如

#tri_afterdelete_on_tag_config
DROP TRIGGER IF EXISTS tri_afterdelete_on_tag_config;
DELIMITER $
CREATE TRIGGER tri_afterdelete_on_tag_config AFTER DELETE ON tag_config FOR EACH ROW 
BEGIN
	INSERT INTO hpm_sync.tag_config(id,tag_type,tag_name,tag_type,content,tag_type_name,platform_id,state,oper) VALUES(old.id,old.tag_type,old.tag_name,old.tag_type,old.content,old.tag_type_name,old.platform_id,0,'delete');
END;
$ #這裡

正確,如

#tri_afterdelete_on_tag_config
DROP TRIGGER IF EXISTS tri_afterdelete_on_tag_config;
DELIMITER $
CREATE TRIGGER tri_afterdelete_on_tag_config AFTER DELETE ON tag_config FOR EACH ROW 
BEGIN
	INSERT INTO hpm_sync.tag_config(id,tag_type,tag_name,tag_type,content,tag_type_name,platform_id,state,oper) VALUES(old.id,old.tag_type,old.tag_name,old.tag_type,old.content,old.tag_type_name,old.platform_id,0,'delete');
END$
DELIMITER ; #這裡