1、select into outfile可以導(dǎo)出數(shù)據(jù)到指定目錄下的文件中
創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的龍崗網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
語法:
SELECT ... INTO OUTFILE 'file_name' [CHARACTER SET charset_name] [export_options] export_options: [{FIELDS | COLUMNS} [TERMINATED BY 'string'] [[OPTIONALLY] ENCLOSED BY 'char'] [ESCAPED BY 'char'] ] [LINES [STARTING BY 'string'] [TERMINATED BY 'string']
2、示例如下:
1)查看要導(dǎo)出數(shù)據(jù)的表t1
MySQL> select * from t1; +------+--------+ | id | name | +------+--------+ | 1 | wang | | 2 | steven | | 3 | tiger | | 4 | lilu | +------+--------+ 4 rows in set (0.00 sec)
2)查看導(dǎo)出的文件
[mysql@oneproxy outfile]$ more t1.file 1,"wang" 2,"steven" 3,"tiger" 4,"lilu"
3)創(chuàng)建要導(dǎo)入的表t2;
mysql> create table t2 as select * from t1 where 1=2; Query OK, 0 rows affected (0.03 sec)
4)將導(dǎo)出的數(shù)據(jù)導(dǎo)入t2
mysql> LOAD DATA INFILE '/mysql/outfile/t1.file' INTO TABLE t2 FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; Query OK, 4 rows affected (0.01 sec) Records: 4 Deleted: 0 Skipped: 0 Warnings: 0
5)查看導(dǎo)入的數(shù)據(jù)
mysql> select * from t2; +------+--------+ | id | name | +------+--------+ | 1 | wang | | 2 | steven | | 3 | tiger | | 4 | lilu | +------+--------+ 4 rows in set (0.00 sec)
本文名稱:MySQL之selectintooutfile用法
標(biāo)題來源:http://muchs.cn/article14/iejdde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站收錄、建站公司、手機(jī)網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、營銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)