mysql语法如何把查询结果导出不同格式(CSV、Excel、XML、TXT)
如何利用mysql语法把数据库查询结果以不同格式类型导出出来?下面编程教程网小编给大家简单介绍一下具体实现代码!
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;
以上是编程学习网小编为您介绍的“mysql语法如何把查询结果导出不同格式(CSV、Excel、XML、TXT)”的全面内容,想了解更多关于 mysql 内容,请继续关注编程基础学习网。