日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

sqluldr2

發布時間:2023/12/10 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sqluldr2 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

執行數據導出命令
3.1常規導出 

sqluldr2 hr/hr123@127.0.0.1:1521/XE query="select * from bb_user_t" head=yes file=D:\sqluldr2\File\tmp001.csv

  說明:head=yes???表示輸出表頭

?

  3.2、使用sql參數

sqluldr2 hr/hr123@127.0.0.1:1521/XE sql=query.sql head=yes file=D:\sqluldr2\File\tmp002.csv
  或

sqluldr2 hr/hr123@127.0.0.1:1521/XE sql=D:\sqluldr2\query.sql head=yes file=D:\sqluldr2\File\tmp002.csv

  query.sql的內容為:

select * from bb_user_t


  3.3、使用log參數
  當集成sqluldr2在腳本中時,就希望屏蔽上不輸出這些信息,但又希望這些信息能保留,這時可以用“LOG”選項來指定日志文件名。

sqluldr2 hr/hr123@127.0.0.1:1521/XE sql=D:\sqluldr2\query.sql head=yes file=D:\sqluldr2\File\tmp003.csv log=+D:\sqluldr2\File\tmp003.log


  3.4、使用 table 參數

  (“TABLE”選項用于指定將文件導入的目標表的名字,例如我們將EMP 表的數據導入到EMP_HIS 表中,假設這兩個表的表結構一致,先用如下命令導出數據:

Sqluldr2 … query=”select * from emp” file=emp.txt table=emp_his ……)
  當使用 table 參數時,在目錄下會生成對應的ctl控制文件,如下語句會生成temp_004_sqlldr.ctl文件。

sqluldr2 hr/hr123@127.0.0.1:1521/XE query="select * from bb_user_t" table=temp_004 head=yes file=D:\sqluldr2\File\tmp004.csv
  可以指定文件地址(不建議,指定文件地址情況重新導入數據庫時需要手動修改生成的D:\sqluldr2\File\temp_004_sqlldr.ctl文件中“INTO TABLE D:\sqluldr2\File\temp_004”為表名“INTO TABLE temp_004”):

  sqluldr2 hr/hr123@127.0.0.1:1521/XE query="select * from bb_user_t" table=D:\sqluldr2\File\temp_004 head=yes file=D:\sqluldr2\File\tmp004.csv(不建議使用)

  生成的控制文件temp_004_sqlldr.ctl的內容如下:

?

  3.4、大數據量操作

  對于大表可以輸出到多個文件中,指定行數分割或者按照文件大小分割,例如:

sqluldr2 hr/hr123@127.0.0.1:1521/XE query="select * from bb_user_t" table=temp_001 mode=APPEND head=yes file=D:\sqluldr2\temp_001_%B.csv batch=yes rows=500000


?

  當文件名(“FILE”選項)的后綴以小寫的“.gz”結尾時,會將記錄直接寫入到GZIP格式的壓縮文件中,如果要歸檔大量數據,這個功能可以節約很多的存貯空間,降低運營成本。

sqluldr2 hr/hr123@127.0.0.1:1521/XE query="select * from bb_user_t" table=temp_001 mode=APPEND head=yes file=D:\sqluldr2\temp_001.txt.gz

  1 兆大小的文件,以GZIP 壓縮方式生成時,大小才90KB,如果用于歸檔歷史數據,的確可以節約不少空間,GZIP 目前是性價比非常好的壓縮方式之一。

參數說明:

user = username/password@tnsname

sql = SQL file name

query = select statement (選擇語句;query參數如果整表導出,可以直接寫表名,如果需要查詢運算和where條件,query=“sql文本”,也可以把復雜sql寫入到文本中由query調用)

field = separator string between fields (

設置導出文件里的分隔符;

默認是逗號分隔符,通過 field參數指定分隔符;

例如現在要改變默認的字段分隔符,用“#”來分隔記錄,導出的命令如下所示:
sqluldr2??test/test sql=tmp.sql field=#
  在指定分隔符時,可以用字符的ASCII代碼(0xXX,大寫的XX為16進制的ASCII碼值)來指定一個字符,常用的字符的ASCII代碼如下:
  回車=0x0d,換行=0x0a,TAB鍵=0x09,|=0x7c,&=0x26,雙引號=0x22,單引號=0x27
  在選擇分隔符時,一定不能選擇會在字段值中出現的字符)

record = separator string between records (記錄之間的分隔字符串;分隔符??指定記錄分隔符,默認為回車換行,Windows下的換行)

rows = print progress for every given rows (default, 1000000)

file = output file name(default: uldrdata.txt) (輸出文件名(默認: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. (目標數據庫的字符集名稱;導出文件里有中文顯示亂碼,需要設置參數charset=UTF8)

ncharset= national character set name of the target database.

parfile = read command option from parameter file (從參數文件讀取命令選項;可以把參數放到parfile文件里,這個參數對于復雜sql很有用)

read = set DB_FILE_MULTIBLOCK_READ_COUNT at session level

sort = set SORT_AREA_SIZE at session level (UNIT:MB)

hash = set HASH_AREA_SIZE at session level (UNIT:MB)

array = array fetch size

head = print row header(Yes|No)

batch = save to new file for every rows batch (Yes/No) (為每行批處理保存新文件)

size = maximum output file piece size (UNIB:MB)

serial = set _serial_direct_read to TRUE at session level

trace = set event 10046 to given level at session level

table = table name in the sqlldr control file (“TABLE”選項用于指定將文件導入的目標表的名字,例如我們將EMP 表的數據導入到EMP_HIS 表中,假設這兩個表的表結構一致,先用如下命令導出數據:

Sqluldr2 … query=”select * from emp” file=emp.txt table=emp_his ……)

control = sqlldr control file and path.

mode = sqlldr option, INSERT or APPEND or REPLACE or TRUNCATE

buffer = sqlldr READSIZE and BINDSIZE, default 16 (MB)

long = maximum long field size

width = customized max column width (w1:w2:...)

quote = optional quote string (可選引用字符串;引號符??指定非數字字段前后的引號符)

data = disable real data unload (NO, OFF)

alter = alter session SQLs to be execute before unload

safe = use large buffer to avoid ORA-24345 error (Yes|No) (使用大緩沖器避免ORA-24345錯誤;ORA-24345: A Truncation or null fetch error occurred,設置參數safe=yes)

crypt = encrypted user information only (Yes|No)

sedf/t = enable character translation function

null = replace null with given value

escape = escape character for special characters

escf/t = escape from/to characters list

format = MYSQL: MySQL Insert SQLs, SQL: Insert SQLs.

exec = the command to execute the SQLs.

prehead = column name prefix for head line.

rowpre = row prefix string for each line.

rowsuf = row sufix string for each line.

colsep = separator string between column name and value.

presql = SQL or scripts to be executed before data unload.

postsql = SQL or scripts to be executed after data unload.

lob = extract lob values to single file (FILE).

lobdir = subdirectory count to store lob files .

split = table name for automatically parallelization.

degree = parallelize data copy degree (2-128).

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</span>

?每個數值以#間隔,每行數據以0x0d0x0a間隔

sqluldr2 hr/hr123@127.0.0.1:1521/XE query="select vip_card from bb_user_t" table=temp_001 mode=APPEND record=0x0d0x0a field=# head=yes file=D:\sqluldr2\temp_001.txt
?

總結

以上是生活随笔為你收集整理的sqluldr2的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。