oracle匯出大數量資料到檔案sqluldr2

hexiaomail發表於2010-11-04
 
在oracle中,當要匯出表的資料時,由於資料量巨大,匯出的工作顯得有點困難,現提供有如下幾種方式:
1、imp/exp工具,匯出來的是dmp檔案,如果想要excel或txt就顯得有點難;
2、PLSQL Developer開發工具,它也能實現匯入資料,而且可以匯出不同的格式,但是在匯出資料的行數會存在一定的問題,一般在70-80萬行還算正常,上百萬的時候就可能有問題;
3、用spool,這是一種好方法;在使用時可以選擇不將結是顯示在螢幕,這就是同時要加上set term off,而且將語句放入SQL檔案,以@run.sql方式執行;
4、網上的一個工具ociuldr,但它只匯出為txt檔案,這個工具速度超快。

D:\ociuldr>sqluldr2

SQL*UnLoader: Fast Oracle Text Unloader (GZIP, Parallel), Release 4.0.1
(@) Copyright Lou Fangxin (AnySQL.net) 2004 - 2010, all rights reserved.

Usage: SQLULDR2 keyword=value [,keyword=value,...]

Valid Keywords:
  user    = username/password@tnsname
  sql     = SQL file name
  query   = select statement
  field   = separator string between fields
  record  = separator string between records
  rows    = print progress for every given rows (default, 1000000)
  file    = output file name(default: uldrdata.txt)
  log     = log file name, prefix with + to append mode
  fast    = auto tuning the session level parameters(YES)
  text    = output type (MYSQL, CSV, MYSQLINS, ORACLEINS, FORM, SEARCH).
  charset = character set name of the target database.
  ncharset= national character set name of the target database.
  parfile = read command option from parameter file

 for field and record, you can use '0x' to specify hex character code,
 \r=0x0d \n=0x0a |=0x7c ,=0x2c, \t=0x09, :=0x3a, #=0x23, "=0x22 '=0x27


E:\music\ociuldr>sqluldr2 user=music/iwie_0925bmc@dbserver query="select t.mbno
from t_sp_inbox t where  t.intime>to_date('20100401', 'yyyymmdd') and (t.msg lik
e 'VV1%' or t.msg like 'VV2%')" field=, record=0x0a file=E:\music\kkk.txt
      0 rows exported at 2010-10-11 09:38:42, size 0 MB.
1000000 rows exported at 2010-10-11 09:38:46, size 8 MB.
1657868 rows exported at 2010-10-11 09:38:49, size 19 MB.
        output file E:\music\kkk.txt closed at 1657868 rows, size 19 MB.

D:\ociuldr>

------------End---------------

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9932141/viewspace-677387/,如需轉載,請註明出處,否則將追究法律責任。

相關文章