主頁 > 知識庫 > mysql 導(dǎo)出CSV文件 并帶表頭的方法

mysql 導(dǎo)出CSV文件 并帶表頭的方法

熱門標(biāo)簽:呼叫中心市場需求 網(wǎng)站排名優(yōu)化 鐵路電話系統(tǒng) 地方門戶網(wǎng)站 服務(wù)外包 AI電銷 Linux服務(wù)器 百度競價排名

參考官方文檔 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;

實例如下:

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);

先查看一下結(jié)果

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)

導(dǎo)出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 導(dǎo)出CSV文件 并帶表頭的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • Mysql 導(dǎo)入導(dǎo)出csv 中文亂碼問題的解決方法
  • MySQL如何導(dǎo)入csv格式數(shù)據(jù)文件解決方案
  • MySQL 導(dǎo)出數(shù)據(jù)為csv格式的方法
  • PHP導(dǎo)出MySQL數(shù)據(jù)到Excel文件(fputcsv)
  • mysql使用SQLyog導(dǎo)入csv數(shù)據(jù)不成功的解決方法
  • php將csv文件導(dǎo)入到mysql數(shù)據(jù)庫的方法
  • mysql導(dǎo)出查詢結(jié)果到csv的實現(xiàn)方法
  • Python實現(xiàn)將MySQL數(shù)據(jù)庫表中的數(shù)據(jù)導(dǎo)出生成csv格式文件的方法
  • 解析csv數(shù)據(jù)導(dǎo)入mysql的方法
  • 使用navicat將csv文件導(dǎo)入mysql

標(biāo)簽:蘭州 銅川 湘潭 崇左 衡水 湖南 仙桃 黃山

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《mysql 導(dǎo)出CSV文件 并帶表頭的方法》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266