当前位置:Gxlcms > mysql > mysql命令行创建存储过程

mysql命令行创建存储过程

时间:2021-07-01 10:21:17 帮助过:110人阅读

问题: mysql用命令行创建存储过程时,如语句中遇到;则创建过程结束,提示 ERROR1064(42000):YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondsto yourMySQLserverversionfortherightsyntaxtousenear''atline n 解决方法: 创建前用delimiter $$


问题:

mysql用命令行创建存储过程时,如语句中遇到;则创建过程结束,提示

ERROR 1064 (42000): 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 '' at line n


解决方法:

创建前用delimiter $$ (修改结束符号;为$$)

创建存储过程的语句
最后用delimiter ; (恢复原来默认的结束符号为;)

一个例子:

DELIMITER $$


CREATE DEFINER=`root`@`%` PROCEDURE `jcsj_bak_procedure`()
BEGIN
insert into tab_zygl_jcsj_bak
select id,sb_id,jcdlx_id,zb,zbz,jcsj from tab_zygl_jcsj
where DATE_FORMAT(jcsj,'%Y-%m-%d') = date_sub(curdate(),interval 1 day);
commit;
delete from tab_zygl_jcsj where DATE_FORMAT(jcsj,'%Y-%m-%d') = date_sub(curdate(),interval 1 day);
commit;
END
$$


DELIMITER ;

人气教程排行