MySQL 将查询结果数据导出(转换)为 CSV 格式文件,结合自带的分隔等关键字语句可现实,具体如下。
推荐方式
SELECT id, title, description, content
FROM article
WHERE category = 'mysql'
INTO OUTFILE '/var/lib/mysql-files/category-mysql.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';