mysql 导出CSV文件 并带表头的方法

如上那篇mysql 导出CSV文件
并带表头的章程便是小编分享给大家的全体内容了,希望能给大家1个参阅,也希望我们多多协理脚本之家。

mysql 导出CSV文件 并带表头的办法,mysqlcsv

参谋官方文书档案 http://dev.mysql.com/doc/refman/5.7/en/select-into.html

mysql> select game,domain,type

-> into outfile 'd:\\game.csv' 
-> fields terminated by ','

-> lines terminated by '\n'

-> from game_lists limit 10;

manbetx手机网页版,实例如下:

mysql> create table test(id int(10) not null auto_increment primary key, name varchar(10) not null,age tinyint(2) not null)engine=innodb default charset=utf8;

mysql> insert into test(`name`,`age`) values ('Lee',20),('Li',30),('Wang',22),('Feng',23);

先查看一下结出

mysql> select * from (select 'name','age' union select name,age from test) b;
+------+-----+
| name | age |
+------+-----+
| name | age |
| Lee | 20 |
| Li  | 30 |
| Wang | 22 |
| Feng | 23 |
+------+-----+
5 rows in set (0.00 sec)

导出CSV文件

mysql> select * into outfile 'd:\\tmp\\columns.csv' fields terminated by ',' lines terminated by '\n' from (select 'name','age' union select name,age from test) b;
Query OK, 5 rows affected (0.00 sec)

以上那篇mysql 导出CSV文件
并带表头的法子就是我分享给大家的全体内容了,希望能给我们一个参考,也意在我们多多帮衬帮客之家。

http://www.bkjia.com/Mysql/1209188.htmlwww.bkjia.comtruehttp://www.bkjia.com/Mysql/1209188.htmlTechArticlemysql 导出CSV文件 并带表头的措施,mysqlcsv
参照他事他说加以调查官方文书档案 http://dev.mysql.com/doc/refman/5.7/en/select-into.html
mysql select game,domain,type- into outfile ‘d:\\g…

实比方下:

mysql> select * into outfile 'd:\\tmp\\columns.csv' fields terminated by ',' lines terminated by '\n' from (select 'name','age' union select name,age from test) b;
Query OK, 5 rows affected (0.00 sec)

导出CSV文件

mysql> create table test(id int(10) not null auto_increment primary key, name varchar(10) not null,age tinyint(2) not null)engine=innodb default charset=utf8;

mysql> insert into test(`name`,`age`) values ('Lee',20),('Li',30),('Wang',22),('Feng',23);
mysql> select * from (select 'name','age' union select name,age from test) b;
+------+-----+
| name | age |
+------+-----+
| name | age |
| Lee | 20 |
| Li  | 30 |
| Wang | 22 |
| Feng | 23 |
+------+-----+
5 rows in set (0.00 sec)
mysql> select game,domain,type

-> into outfile 'd:\\game.csv' 
-> fields terminated by ','

-> lines terminated by '\n'

-> from game_lists limit 10;

您或然感兴趣的小说:

先查看一下结出

参考官方文书档案 http://dev.mysql.com/doc/refman/5.7/en/select-into.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图