新聞中心
MySQL查詢結(jié)果導(dǎo)出到文件的方法很多人都會,一般大家都會用 “SELECT INTO OUTFIL”將查詢結(jié)果導(dǎo)出到文件,但是這種MySQL查詢結(jié)果導(dǎo)出到文件方法不能覆蓋或者添加到已經(jīng)創(chuàng)建的文件。例如:

10多年的平輿網(wǎng)站建設(shè)經(jīng)驗(yàn),針對設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整平輿建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)從事“平輿網(wǎng)站設(shè)計(jì)”,“平輿網(wǎng)站推廣”以來,每個客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
- mysql> select 1 into outfile '/tmp/t1.txt';
- Query OK, 1 row affected (0.00 sec)
- mysql> select 1 into outfile '/tmp/t1.txt';
- ERROR 1086 (HY000): File '/tmp/t1.txt' already exists
還可以使用另外一種方法:
- mysql> pager cat > /tmp/t1.txt
- PAGER set to 'cat > /tmp/t1.txt'
- mysql> select 1;\! cat /tmp/t1.txt
- 1 row in set (0.00 sec)
- +---+
- | 1 |
- +---+
- | 1 |
- +---+
這樣你能很方便的查詢到2條sql的差異:
- mysql> pager cat > /tmp/t01.txt
- PAGER set to 'cat > /tmp/t01.txt'
- mysql> select 12345 union select 67890;
- 2 rows in set (0.02 sec)
- mysql> pager cat > /tmp/t02.txt
- PAGER set to 'cat > /tmp/t02.txt'
- mysql> select 12345 union select 67891;
- 2 rows in set (0.00 sec)
- mysql> \! vimdiff -o /tmp/t0[12].txt
- 2 files to edit
- +-------+
- | 12345 |
- +-------+
- | 12345 |
- | 67890 |
- +-------+
- /tmp/t01.txt
- +-------+
- | 12345 |
- +-------+
- | 12345 |
- | 67891 |
- +------+
- /tmp/t02.txt
【編輯推薦】
MySQL查詢結(jié)果條數(shù)編號示例
MySQL查詢分頁的優(yōu)化
MySQL查詢結(jié)果按某值排序
使用函數(shù)實(shí)現(xiàn)MySQL查詢行號
MySQL查詢中的非空問題
文章題目:MySQL查詢結(jié)果導(dǎo)出到文件的另類方法
本文來源:http://m.fisionsoft.com.cn/article/dhcdsjh.html


咨詢
建站咨詢
