SELECT CONCAT("mysqldump -uroot -p ", TABLE_SCHEMA, " ", TABLE_NAME, " >> ", TABLE_SCHEMA, ".bak.sql")
FROM INFORMATION_SCHEMA WHERE TABLE_NAME LIKE 'Country%';
還可以把生成的shell命令儲存在檔案裡(但必須是本地資料夾,或者客戶端所在的主機資料夾, 也或者 mapped 的server資料夾,並且檔案不存在)
SELECT CONCAT("mysqldump -uroot -p ", TABLE_SCHEMA, " ", TABLE_NAME, " >> ", TABLE_SCHEMA, ".bak.sql")
FROM INFORMATION_SCHEMA WHERE TABLE_NAME LIKE 'Country%'
INTO OUTFILE 'C:/sample.sh';
concat() 方法是字串連線方法, 若含有Null, 則結果為Null ,具體參見
http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_concat