mysql> show tables;
+---------------------+
| Tables_in_cpsc408db |
+---------------------+
| Product |
| laptop |
| pc |
| printer |
+---------------------+
4 rows in set (0.00 sec)
mysql> create procedure hello()
-> begin
-> select * from product;
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 3
mysql>
我不确定是什么导致了这种语法错误,到目前为止还没有取得任何成功。任何帮助将不胜感激。
答案 0 :(得分:1)
您需要使用DELIMITER关键字:
这样MySQL可以判断程序中的哪些语句以及程序声明本身的结尾
delimiter //
CREATE PROCEDURE hello()
BEGIN
select * from product;
END//
delimiter ;
答案 1 :(得分:0)
您需要一个分隔符,否则控制台不知道您何时完成:
DELIMITER //
CREATE PROCEDURE hello()
BEGIN
SELECT * FROM product;
END //
DELIMITER ;