北國狼人的部落格
BlogJava
首頁
新隨筆
聯系
聚合
管理
隨筆-159 評論-114 文章-7 trackbacks-0
mysql查詢結果導出到文件另一方法
一般大家都會用 “SELECT INTO OUTFIL”將查詢結果導出到文件,但是這種方法不能覆蓋或者添加到已經創建的文件。例如:
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
posted on 2009-09-29 15:43
北國狼人的BloG
閱讀(2548)
評論(0)
編輯
收藏
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
<
2009年9月
>
日
一
二
三
四
五
六
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(33)
給我留言
查看公開留言
查看私人留言
隨筆分類
3D至尊寶(1)
人生各層面經驗積累(15)
關愛IT人士健康(15)
達內學習總結(42)
隨筆檔案
2018年11月 (2)
2012年3月 (1)
2011年8月 (1)
2011年1月 (1)
2010年12月 (2)
2010年8月 (1)
2010年6月 (3)
2010年5月 (3)
2010年4月 (11)
2010年3月 (8)
2010年2月 (4)
2010年1月 (4)
2009年12月 (6)
2009年11月 (1)
2009年10月 (3)
2009年9月 (3)
2009年8月 (3)
2009年6月 (1)
2009年5月 (1)
2009年4月 (1)
2009年1月 (1)
2008年12月 (1)
2008年11月 (3)
2008年10月 (1)
2008年8月 (4)
2008年6月 (2)
2008年5月 (3)
2008年3月 (1)
2008年2月 (1)
2008年1月 (2)
2007年12月 (2)
2007年10月 (3)
2007年9月 (1)
2006年11月 (1)
2006年9月 (1)
2006年8月 (3)
2006年7月 (2)
2006年6月 (1)
2006年5月 (1)
2006年4月 (5)
2006年3月 (7)
2006年2月 (7)
2006年1月 (12)
2005年12月 (8)
2005年11月 (19)
2005年10月 (9)
文章分類
3D至尊寶
Web技術和趨勢(1)
原創(1)
翻譯Java文章(2)
文章檔案
2006年10月 (1)
2005年10月 (3)
Java學習論壇
3D至尊寶
Java最牛網站
搜索
最新評論
1.?re: xsl:value-of select="." 什么意思?[未登錄]
ffff
--ff
2.?re: 理解Java ClassLoader機制 |用Java說話,人氣戰勝時間!Come On
好文章
--godtree
3.?re: 理解Java ClassLoader機制 |用Java說話,人氣戰勝時間!Come On[未登錄]
好文章,收了,謝謝博主
--thinker
4.?re: 高效產生一組不重復的隨機數
要是要求產生的隨機數量特別大怎么辦啊
--ll
5.?re: AS3 位操作比較快
“看完還不明白,就不要搞計算機了。”
就沖著此話,為樓主的優越感深表擔憂
每個人都是從新手過來的,樓主發帖如果是為了分享,我很敬佩,如果是為了和裝13,那我只能笑笑
--調整心態啊樓主
閱讀排行榜
1.?RCP開發,如何解決 org.eclipse.core.runtime.CoreException: Plug-in TD was unable to load class td.app.Application.(14353)
2.?mysql_install_db --defaults-file=/etc/my.cnf --user=mysql(8191)
3.?IWAB0014E Unexpected exception occured 該死的問題,就是因為Eclipse + WTP 需要先配置Server,再生成webservice(6958)
4.?理解Java ClassLoader機制 |用Java說話,人氣戰勝時間!Come On(6497)
5.?J2ME 網絡連接(HTTP) 模擬器 WTK(4984)
評論排行榜
1.?RCP開發,如何解決 org.eclipse.core.runtime.CoreException: Plug-in TD was unable to load class td.app.Application.(9)
2.?給自己的軟件加保險,用java獲取硬盤序列號(8)
3.?不要寫垃圾代碼!!!(8)
4.?反日行動從現在開始,從每個中國人,每個程序員做起!不用日本東西,不給日本人打工!!!(8)
5.?IWAB0014E Unexpected exception occured 該死的問題,就是因為Eclipse + WTP 需要先配置Server,再生成webservice(7)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 北國狼人的BloG
主站蜘蛛池模板:
山阴县
|
湖州市
|
封丘县
|
石泉县
|
泗洪县
|
阜平县
|
漳浦县
|
池州市
|
宣汉县
|
三亚市
|
泽州县
|
墨脱县
|
东乌珠穆沁旗
|
石阡县
|
上饶市
|
红安县
|
郓城县
|
云阳县
|
灌阳县
|
吉水县
|
大庆市
|
阜新市
|
南木林县
|
芦溪县
|
汉源县
|
苍南县
|
夏河县
|
延津县
|
黔西县
|
朔州市
|
永康市
|
长沙县
|
资溪县
|
蒲江县
|
会泽县
|
白沙
|
凌源市
|
扶余县
|
西林县
|
凌云县
|
七台河市
|