隨筆-159  評論-114  文章-7  trackbacks-0

          一般大家都會用 “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 閱讀(2551) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 洛扎县| 台北县| 正蓝旗| 宾川县| 蓝田县| 资中县| 湾仔区| 盐城市| 岳阳县| 崇礼县| 左云县| 高阳县| 泗洪县| 逊克县| 沛县| 勃利县| 江源县| 兴和县| 武清区| 凤翔县| 桂东县| 宁安市| 中宁县| 武隆县| 利津县| 苏尼特左旗| 太仆寺旗| 巴林右旗| 灵台县| 安徽省| 蓬安县| 大同县| 通山县| 麦盖提县| 温州市| 忻城县| 千阳县| 阿克| 台北县| 通道| 永济市|