mysql 是最流行的关系型数据库管理系统之一,mysql中我们可以使用select...into outfile语句来简单的导出数据到文本文件上。
使用 select ... into outfile 语句导出数据
以下实例中我们将数据表 demo_tbl 数据导出到 /tmp/demo.txt 文件中:
mysql> select * from demo_tbl -> into outfile '/tmp/demo.txt';
你可以通过命令选项来设置数据输出的指定格式,以下实例为导出 csv 格式:
mysql> select * from passwd into outfile '/tmp/demo.txt' -> fields terminated by ',' enclosed by '"' -> lines terminated by '\r\n';
在下面的例子中,生成一个文件,各值用逗号隔开。
这种格式可以被许多程序使用。
select a,b,a+b into outfile '/tmp/result.text'fields terminated by ',' optionally enclosed by '"'lines terminated by '\n'from test_table;
以上就是怎么将mysql数据导出的详细内容。