問題描述
我正在使用以下 sql:
I am using the following sql:
DELIMITER $$
DROP PROCEDURE IF EXISTS `get_auto_increment_settings`$$
CREATE PROCEDURE `get_auto_increment_settings`()
BEGIN
select @@global.auto_increment_offset as 'offset', @@global.auto_increment_increment as 'increment' ;
END $$
DELIMITER ;
我將它存儲在 db_auto_increment_settings_procedure.sql 中,當(dāng)我嘗試從 ant 執(zhí)行它時,我面臨以下錯誤:
I stored this in db_auto_increment_settings_procedure.sql and when I am trying to execute this from ant, I am facing the following error:
[sql] Executing resource: /mysql/install/db_auto_increment_settings_procedure.sql
[sql] Failed to execute: DELIMITER
[sql] com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 'DELIMITER' at line 1
[sql] Failed to execute: DELIMITER ;
[sql] com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 'DELIMITER' at line 1
推薦答案
分隔符僅用于 mysql 客戶端(不適用于 API、驅(qū)動程序等).
所以,這行不通.
The delimiter is used only by mysql client (not on API, driver ... etc).
So, it won't work.
查看您的錯誤消息:-
[sql] Executing resource: /mysql/install/db_auto_increment_settings_procedure.sql
[sql] Failed to execute: DELIMITER
很確定這將在 linux 系統(tǒng)中工作
Pretty sure this will work in linux system
mysql -u root -pxxx -h yyy < YOUR_SQL.sql
如果適用,您只需使用 mysql 客戶端手動創(chuàng)建存儲過程,
并且是一個沒有汗水的解決方案.
If applicable, you just manually create the stored procedure using mysql client,
and is a no-sweat solution.
如果你需要動態(tài)創(chuàng)建這個,
該文檔可能會提供一些見解信息
http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-basic.html
If you need to create this dynamically,
this doc might provide some insight information
http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-basic.html
這篇關(guān)于MySql 中的 DELIMITER 錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!