2024年10月07日 建站教程
如何利用mysql语法把数据库查询结果以不同格式类型导出出来?下面web建站小编给大家简单介绍一下具体实现代码!
mysql查询并导出为CSV文件
SELECT * INTO OUTFILE 'test.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM table_name;
mysql查询并导出为Excel文件
SELECT * INTO OUTFILE 'test.xls' FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' FROM table_name;
mysql查询并导出为XML文件
SELECT * FROM table_name INTO OUTFILE 'test.xml' ROWS IDENTIFIED BY '<row>';
mysql查询并导出为TXT文件
SELECT * INTO OUTFILE 'test.txt' FROM table_name;
本文链接:http://so.lmcjl.com/news/14847/