2017-01-31 89 views

回答

0

MySQL不提供此功能,但它是由lib_mysqludf_sys庫提供的。如果您安裝了,你就可以調用它sys_exec函數來執行命令:

DELIMITER @@ 

CREATE TRIGGER Test_Trigger 
AFTER INSERT ON MyTable 
FOR EACH ROW 
BEGIN 
DECLARE cmd CHAR(255); 
DECLARE result int(10); 
SET cmd=('mv path/to/file new/path/file'); 
SET result = sys_exec(cmd); 
END; 
@@ 
DELIMITER ; 

(我發現這種方法在http://crazytechthoughts.blogspot.com/2011/12/call-external-program-from-mysql.html