Home >Database >Mysql Tutorial >mysql 命令行创建存储过程

mysql 命令行创建存储过程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 15:34:571789browse

问题: 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 ; 



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn