隨筆-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 閱讀(2548) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 集安市| 沙田区| 砀山县| 乳源| 潮州市| 马尔康县| 怀来县| 新竹县| 阿坝| 东乡族自治县| 平南县| 正安县| 新郑市| 桦川县| 武义县| 青岛市| 新晃| 建德市| 新田县| 赤城县| 宣恩县| 微博| 进贤县| 旺苍县| 蓝田县| 响水县| 石首市| 永胜县| 若羌县| 化隆| 伊宁市| 乌鲁木齐县| 松江区| 长沙县| 禹城市| 建德市| 中宁县| 福贡县| 建宁县| 葫芦岛市| 涞水县|