使用MySQL,如何使用phpmyadmin將用戶定義的數據庫函數從一個數據庫服務器導入到另一個數據庫服務器?MySQL,phpmyadmin,如何導入用戶定義的函數
select * from information_schema.routines;
這裏是我的功能,我想移動到不同的數據庫服務器:
的用戶定義的函數列表可以使用這個SQL是牽強
CREATE DEFINER=`XXX`@`%` FUNCTION `BDayDiff`(d1 DATE, d2 DATE) RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE dow1, dow2, days, wknddays INT;
SET dow1 = DAYOFWEEK(d1);
SET dow2 = DAYOFWEEK(d2);
SET days = DATEDIFF(d2,d1);
SET wknddays = 2 * FLOOR(days/7) +
IF(dow1 = 1 AND dow2 > 1, 1,
IF(dow1 = 7 AND dow2 = 1, 1,
IF(dow1 > 1 AND dow1 > dow2, 2,
IF(dow1 < 7 AND dow2 = 7, 1, 0)
)
)
);
RETURN FLOOR(days - wkndDays);
END
但我得到一個錯誤:
Error
SQL query:
CREATE DEFINER = `XXX`@`%` FUNCTION `BDayDiff` (
d1 DATE,
d2 DATE
) RETURNS INT(11) DETERMINISTIC BEGIN DECLARE dow1,
dow2,
days,
wknddays INT;
MySQL said: Documentation
#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 '' at line 5
謝謝Devart,我創建了查詢來創建函數,但不知何故它拋出錯誤。我更新了上面的問題,錯誤。任何想法? – Developer
它可以是一箇舊的phpmyadmin版本DELIMITER問題 - http://stackoverflow.com/questions/2846516/how-to-write-a-stored-procedure-using-phpmyadmin-and-how-to-use-it-通過php – Devart
您也可以嘗試使用PHP的MySQL擴展來創建過程。 – Devart