Refer to the official document 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; The following are examples: 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); Check the results first 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) Export CSV file 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) The above method of exporting MySQL CSV files with headers is all I have to share with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Alibaba Cloud Server Ubuntu Configuration Tutorial
>>: Let’s take a look at JavaScript precompilation (summary)
Overview of Alibaba Cloud Security Group Sharing ...
1. Introduction The main value that SELinux bring...
Problem explanation: When using the CSS animation...
This article shares the specific code of JavaScri...
The SQL JOIN clause is used to join rows from two...
What is a table? It is composed of cell cells. In...
I have been taking a lot of MySQL notes recently,...
This is the installation tutorial of mysql5.7.18....
As a commonly used database, MySQL requires a lot...
1. Background Although I have read many blogs or ...
This article mainly introduces 6 solutions to the...
Table of contents 1. Introduction 1.1 Babel Trans...
Table of contents How to rename MySQL database Th...
Achieve resultsImplementation Code html <heade...
Copy code The code is as follows: <style type=...