久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

ORACLE怎么進行導入導出數據

151次閱讀
沒有評論

共計 9660 個字符,預計需要花費 25 分鐘才能閱讀完成。

本篇內容介紹了“ORACLE 怎么進行導入導出數據”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓丸趣 TV 小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

簡介:

Sqluldr2:專業用于大數據量導出工具之一,效率比普通導出快 70%。( Sqlldr:專業用于導入的工具之一,請注意兩個工具的區別。), 在使用時, 最好用磁盤寫入速度快,網絡好,網速快的做。

工具列表:

針對不同平臺用不同的導出工具:

Windows:  sqluldr2.exe

Linux(32 位):sqluldr2_linux32_10204.bin

Linux(64 位):  sqluldr2_linux64_10204.bin

使用說明(Windows 平臺):

使用 sqluldr2 的步驟:

1. 打開運行àcmd 進入到 sqluldr2.exe 的當前目錄

2. 參數介紹

User= 用戶 / 密碼 @tns

Query=”查詢語句”

File= 導出的路徑

Head= 輸出信息時,yes 表示要表頭,no 表示不要表頭

注意:想查看更多參數,請輸入 sqluldr2 help=yes

C:\Users\meng\Desktop\sqluldr2 sqluldr2.exe help=yes 

 

 

SQL*UnLoader: Fast Oracle Text Unloader (GZIP, Parallel), Release 4.0.1 

(@) Copyright Lou Fangxin (AnySQL.net) 2004 – 2010, all rights reserved. 

 

 

License: Free for non-commercial useage, else 100 USD per server. 

 

 

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 

 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 

 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) 

 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). 

 hint = MySQL SQL hint for the Insert, for example IGNORE. 

 unique = Unique Column List for the MySQL target table. 

 update = Enable MySQL ON DUPLICATE SQL statement(YES/NO). 

 

 

 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 

 

C:\Users\meng\Desktop\sqluldr2  

 

代碼例子 1:

sqluldr2.exe USER= 用戶 / 密碼 @tnsQUERY= select  /*+ parallel(8)  */  *from cs_XXX dt,cfg_XXX devdim105 wheredt.starttime =to_date(2012-06-27 00:00:00 , yyyy-mm-dd hh34:mi:ss) and dt.starttime =to_date(2012-06-2700:01:59 , yyyy-mm-dd hh34:mi:ss) AND dt.msc= devdim105.mapvalue(+) ANDdevdim105.deviceid=15 head=yes FILE=F:\cs_XXX_test.csv

代碼例子 2(這種方式用于導出的查詢 sql 很長,那么就把 sql 寫在 123.sql 文件里):

sqluldr2.exe USER= 用戶 / 密碼 @tns  sql=123.sqlhead=yes FILE=F:\cs_XXX_test.csv

3. 在 cmd 里,直接把步驟 2 的代碼例子 1,貼進去執行。

注:如果執行報報錯,就有可能是環境變量 path 的問題,還有就是 plsql 需要的 oci.dll 文件等多個 dll 文件,請放在 sqluldr2 的目錄下。

4. 查看結果 F:\cs_XXX_test.csv

5. 打開 csv 里面的內容,就可以用 sqlldr 進行 入庫。

– 如果是 linux 版本

[root@localhost export_xdr]# ./sqluldr2_linux64_10204.bin 

 

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 

 

[root@localhost export_xdr]# cd /usr/lib/oracle/11.2/client64/lib/ 

[root@localhost lib]# ls 

glogin.sql libclntsh.so.10.1 libnnz11.so libocci.so.11.1 libocijdbc11.so libsqlplus.so ojdbc6.jar xstreams.jar 

libclntsh.so libclntsh.so.11.1 libocci.so libociei.so libsqlplusic.so ojdbc5.jar ottclasses.zip 

[root@localhost lib]# ls -l 

total 185012 

-rw-r–r– 1 root root 368 Sep 17 2011 glogin.sql 

lrwxrwxrwx 1 root root 17 Jan 26 17:08 libclntsh.so –  libclntsh.so.11.1 

lrwxrwxrwx 1 root root 12 Jan 26 17:31 libclntsh.so.10.1 –  libclntsh.so 

-rw-r–r– 1 root root 52761218 Sep 17 2011 libclntsh.so.11.1 

-rw-r–r– 1 root root 7955322 Sep 17 2011 libnnz11.so 

lrwxrwxrwx 1 root root 15 Jan 26 17:08 libocci.so –  libocci.so.11.1 

[root@localhost export_xdr]# history |grep ln 

 94 find / -name libclntsh.so.10.1 

 95 find / -name libclntsh.so 

 116 find / -name libclntsh.so 

 127 ln libclntsh.so.10.1 libocci.so 

 128 ln libocci.so libclntsh.so.10.1 

 130 rm libclntsh.so.10.1 -f 

 132 ln libclntsh.so libclntsh.so.10.1 

 134 rm libclntsh.so.10.1 -f 

 135 ln libclntsh.so.10.1 libclntsh.so 

 

./sqluldr2_linux64_10204.bin user=unxx/ 密碼 @192.168.x.x:1521/unxx query= select/*+ parallel(2) */STARTTIME, ENDTIME,phone,imei,rantype,HCITY from v_ps_xxx dt,mv_terminal cc where endtime_par =trunc(sysdate)-1 and endtime_par trunc(sysdate)-1+1/24 and dt.TACID=cc.TACID(+)   head=yes field=0x09 text=txt file= /BigData/export_xdr/exportting.txt.tmp  

 

補充:

兄弟們,在安裝的時候,是不是經常遇到報錯?

比如:

[root@FCJ-2F-21 ~]# ./sqluldr2_linux64_10204.bin 

./sqluldr2_linux64_10204.bin: error while loading shared libraries: libclntsh.so.10.1: cannot open shared object file: No such file or directory 

[root@FCJ-2F-21 ~]# more /etc/profile 

方法一:

這個 so 文件,在安裝 oracle 后,肯定是有的,如果沒有可以用軟連接 ln -s xxxx  libclntsh.so.10.1

1. 下面只需配置  LD_LIBRARY_PATH

export ORACLE_HOME=/u01/app/Oracle/product/11.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$PATH:$ORACLE_HOME:$ORACLE_HOME/bin

[oracle@FCJ-2F-21 lib]$ more /etc/profile 

# /etc/profile 

 

# System wide environment and startup programs, for login setup 

# Functions and aliases go in /etc/bashrc 

 

pathmunge () { 

 if ! echo $PATH | /bin/egrep -q  (^|:)$1($|:)  ; then 

 if [  $2  =  after  ] ; then 

 PATH=$PATH:$1 

 else 

 PATH=$1:$PATH 

 fi 

 fi 

 

# ksh workaround 

if [ -z  $EUID  -a -x /usr/bin/id ]; then 

 EUID=`id -u` 

 UID=`id -ru` 

fi 

 

# Path manipulation 

if [  $EUID  =  0  ]; then 

 pathmunge /sbin 

 pathmunge /usr/sbin 

 pathmunge /usr/local/sbin 

fi 

 

# No core files by default 

ulimit -S -c 0   /dev/null 2 1 

 

if [ -x /usr/bin/id ]; then 

 USER= `id -un`  

 LOGNAME=$USER 

 MAIL= /var/spool/mail/$USER  

fi 

 

HOSTNAME=`/bin/hostname` 

HISTSIZE=1000 

 

if [ -z  $INPUTRC  -a ! -f  $HOME/.inputrc  ]; then 

 INPUTRC=/etc/inputrc 

fi 

 

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC 

 

# By default, we want umask to get set. This sets it for login shell 

# Current threshold for system reserved uid/gids is 200 

# You could check uidgid reservation validity in 

# /usr/share/doc/setup-*/uidgid file 

if [ $UID -gt 99 ]   [  `id -gn`  =  `id -un`  ]; then 

 umask 002 

else 

 umask 022 

fi 

 

for i in /etc/profile.d/*.sh ; do 

 if [ -r  $i  ]; then 

 if [  ${-#*i}  !=  $-  ]; then 

 . $i 

 else 

 . $i  /dev/null 2 1 

 fi 

 fi 

done 

 

unset i 

unset pathmunge 

 

export LANG=en_US.UTF-8 

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH 

export TNS_ADMIN=/usr/lib/oracle/11.1/client64/ 

export PATH=$PATH:$ORACLE_HOME:$ORACLE_HOME/bin 

 

2.source /etc/profile

成功。

方法二:(來自其他網友)

  如果共享庫文件安裝到了 /usr/local/lib(很多開源的共享庫都會安裝到該目錄下)或其它 非 /lib 或 /usr/lib 目錄下,  那么在執行 ldconfig 命令前,  還要把新共享庫目錄加入到共享庫配置文件 /etc/ld.so.conf 中,  如下: 

 

# cat /etc/ld.so.conf 

include ld.so.conf.d/*.conf 

# echo  /usr/local/lib    /etc/ld.so.conf 

# ldconfig 

—- 實例演示
下載完 sqluldr2,文件夾內容如下:
sqluldr2_linux32_10204.bin 和 sqluldr2_linux64_10204.bin 分別適用于與 linux32 位和 linux64 位操作系統;
sqluldr2.exe 用于 windows 平臺。

以下是導出導入過程:
1、首先將 sqluldr2.exe 復制到到 $ORACLE_HOME 的 bin 目錄,即可開始使用:

2、查看 help 幫助:

3、執行導出數據命令:
sqluldr2.exe USER=hh/hh@tiod QUERY= select /*+ parallel(2) */  *from hh.ent_person table=ent_person head=yes FILE=C:\ent_person.txt
p.s. head=yes 表示第一行為表頭;并且 query 也可以寫入一個文件然后使用 sql 選項。
默認分隔字符為逗號,如果列中有特殊字符,可使用 field 選項指定新的分隔字符。

4、數據已經導入到 C:\ent_person.txt,幾十萬數據秒速。

5、使用 sqlldr 進行導入,首先找到 $ORACLE_HOME 的 bin 目錄生成的 ctl 文件,當 sqluldr2 有 table 選項會默認生成 ctl 文件,以用于導入。

6、將數據加載到數據庫中:
sqlldr jms/jms@tiod control=ent_person_sqlldr.ctl log=ent_person_sqlldr.log bad=ent_person_sqlldr_bad.log skip=1  errors=5000 rows=5000 bindsize=335542
p.s. skip= 1 表示跳過第一行,從第二行開始導入。

7、最后查看 log 是否有數據沒有導入

“ORACLE 怎么進行導入導出數據”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注丸趣 TV 網站,丸趣 TV 小編將為大家輸出更多高質量的實用文章!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-01發表,共計9660字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 武陟县| 湘乡市| 义马市| 烟台市| 遂昌县| 康乐县| 霍州市| 古交市| 衢州市| 宜兰市| 广河县| 海阳市| 凯里市| 囊谦县| 上饶县| 冀州市| 汉中市| 蛟河市| 临夏市| 大名县| 宜春市| 新乡县| 司法| 休宁县| 方正县| 松溪县| 琼海市| 福泉市| 丘北县| 姚安县| 余庆县| 专栏| 南郑县| 云龙县| 崇仁县| 霞浦县| 广宗县| 涪陵区| 尚志市| 杂多县| 上蔡县|