小弟建立了一个存储过程如下:use userDB;
drop procedure if exists usp_test;
create procedure usp_test()
begin
select * from users;
end;但是报了一个错误:Error Code : 1064
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 'select * from users' at line 3
(0 ms taken)Error Code : 1064
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 'end' at line 1
(0 ms taken)
请问这是怎么回事啊?怎么解决呢?
drop procedure if exists usp_test;
create procedure usp_test()
begin
select * from users;
end;但是报了一个错误:Error Code : 1064
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 'select * from users' at line 3
(0 ms taken)Error Code : 1064
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 'end' at line 1
(0 ms taken)
请问这是怎么回事啊?怎么解决呢?
-> BEGIN
-> SELECT * FROM users;
-> END;
-> //
Query OK, 0 rows affected (0.00 sec)mysql> delimiter ;注意对结束界定符的转换,否则mysql仍以;为结束符,自然会出错。
不过,记得再最后再给转回去。delimiter //
。。
delimiter ;
要不就不可能出现这个错误的。
因为如果你再命令行界面逐行输入的话,当你输入select * from users;这一句后,回车,
还没输入end;的时候,就应该已经报错了。
还是DELIMITER 的问题,必须暂时修改定界符。
否则系统会碰到“;”就执行的。
delimiter的作用就是告诉那个命令行客户端,每次解析到delimiter,就把已输入的SQL数据发送到服务器,而delimiter的默认值是;