激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|數(shù)據(jù)庫技術(shù)|

服務(wù)器之家 - 數(shù)據(jù)庫 - Oracle - Oracle數(shù)據(jù)加載和卸載的實現(xiàn)方法

Oracle數(shù)據(jù)加載和卸載的實現(xiàn)方法

2020-03-31 19:32li0924 Oracle

這篇文章主要介紹了Oracle數(shù)據(jù)加載和卸載的實現(xiàn)方法,非常不錯,具有一定的參考借鑒加載,需要的朋友可以參考下

在日常工作中;經(jīng)常會遇到這樣的需求:

  • Oracle 數(shù)據(jù)表跟文本或者文件格式進行交互;即將指定文件內(nèi)容導(dǎo)入對應(yīng)的 Oracle 數(shù)據(jù)表中;或者從 Oracle 數(shù)據(jù)表導(dǎo)出。
  • 其他數(shù)據(jù)庫中的表跟Oracle數(shù)據(jù)庫進行交互。

  若是少量數(shù)據(jù);可選擇的解決方案有很多。常用的用 Pl/SQL developer工具,或者手動轉(zhuǎn)換為 INSERT 語句,或者通過API。但數(shù)據(jù)量大;用上面的方法效率太爛了。本文來說說 Oracle 數(shù)據(jù)的加載和卸載。

  • Oracle中的DBLINK
  • Oracle加載數(shù)據(jù)-外部表
  • Oracle加載數(shù)據(jù)-sqlldr工具
  • Oracle卸載數(shù)據(jù)-sqludr

一. Oracle 中的 DBLINK

  在日常工作中;會遇到不同的數(shù)據(jù)庫進行數(shù)據(jù)對接;每個數(shù)據(jù)庫都有著功能;像Oracle有 DBLINK ; PostgreSQL有外部表。

1.1 Oracle DBlink 語法

CREATE [PUBLIC] DATABASE LINK link
CONNECT TO username
IDENTIFIED BY password
USING 'connectstring'

1.2 Oracle To Mysql

  在oracle配置mysql數(shù)據(jù)庫的dblink

二.Oracle加載數(shù)據(jù)-外部表

  ORACLE外部表用來存取數(shù)據(jù)庫以外的文本文件(Text File)或ORACLE專屬格式文件。因此,建立外部表時不會產(chǎn)生段、區(qū)、數(shù)據(jù)塊等存儲結(jié)構(gòu),只有與表相關(guān)的定義放在數(shù)據(jù)字典中。外部表,顧名思義,存儲在數(shù)據(jù)庫外面的表。當存取時才能從ORACLE專屬格式文件中取得數(shù)據(jù),外部表僅供查詢,不能對外部表的內(nèi)容進行修改(INSERT、UPDATE、DELETE操作)。不能對外部表建立索引。

2.1 創(chuàng)建外部表需要的目錄

?
1
2
3
4
5
6
7
# 創(chuàng)建外部表需要的目錄
SQL> create or replace directory DUMP_DIR as '/data/ora_ext_lottu';
Directory created.
# 給用戶授予指定目錄的操作權(quán)限
SQL> GRANT READ,WRITE ON DIRECTORY DUMP_DIR TO lottu;
 
Grant succeeded.

2.2 外部表源文件lottu.txt

?
1
2
3
4
10,ACCOUNTING,NEW YORK
20,RESEARCH,DALLAS
30,SALES,CHICAGO
40,OPERATIONS,BOSTON

2.3 創(chuàng)建外部表

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
drop table dept_external purge;
 
CREATE TABLE dept_external (
  deptno   NUMBER(6),
  dname   VARCHAR2(20),
  loc    VARCHAR2(25)
)
ORGANIZATION EXTERNAL
(TYPE oracle_loader
 DEFAULT DIRECTORY DUMP_DIR
 ACCESS PARAMETERS
 (
 RECORDS DELIMITED BY newline
 BADFILE 'lottu.bad'
 LOGFILE 'lottu.log'
 FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
 (
  deptno   INTEGER EXTERNAL(6),
  dname   CHAR(20),
  loc    CHAR(25)
 )
 )
 LOCATION ('lottu.txt')
)
REJECT LIMIT UNLIMITED;

查看數(shù)據(jù)

?
1
2
3
4
5
6
7
8
SQL> select * from dept_external;
 
  DEPTNO DNAME LOC
---------- -------------------- -------------------------
 10 ACCOUNTING NEW YORK
 20 RESEARCH DALLAS
 30 SALES CHICAGO
 40 OPERATIONS BOSTON

三. Oracle加載數(shù)據(jù)-sqlldr工具

3.1 準備實驗對象

  創(chuàng)建文件lottu.txt;和表tbl_load_01。

?
1
2
3
4
5
6
7
8
9
10
[oracle@oracle235 ~]$ seq 1000|awk -vOFS="," '{print $1,"lottu",systime()-$1}' > lottu.txt
[oracle@oracle235 ~]$ sqlplus lottu/li0924
SQL*Plus: Release 11.2.0.4.0 Production on Mon Aug 13 22:58:34 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table tbl_load_01 (id number,name varchar2(10),accountid number);
Table created.

3.2 創(chuàng)建控制文件lottu.ctl

?
1
2
3
4
5
6
7
8
9
10
11
12
load data
characterset utf8
    infile '/home/oracle/lottu.txt'
    truncate into table tbl_load_01
    fields terminated by ','
    trailing nullcols
 optionally enclosed by ' ' TRAILING NULLCOLS
(
 id ,
 name,
 accountid
)

3.3 執(zhí)行sqlldr

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[oracle@oracle235 ~]$ sqlldr 'lottu/"li0924"' control=/home/oracle/lottu.ctl log=/home/oracle/lottu.log bad=/home/oracle/lottu.bad
SQL*Loader: Release 11.2.0.4.0 - Production on Mon Aug 13 23:10:12 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 64
Commit point reached - logical record count 128
Commit point reached - logical record count 192
Commit point reached - logical record count 256
Commit point reached - logical record count 320
Commit point reached - logical record count 384
Commit point reached - logical record count 448
Commit point reached - logical record count 512
Commit point reached - logical record count 576
Commit point reached - logical record count 640
Commit point reached - logical record count 704
Commit point reached - logical record count 768
Commit point reached - logical record count 832
Commit point reached - logical record count 896
Commit point reached - logical record count 960
Commit point reached - logical record count 1000

四.Oracle卸載數(shù)據(jù)-sqludr

  sqludr是將Oracle數(shù)據(jù)表導(dǎo)出到文本中;是牛人樓方鑫開發(fā)的。并非Oracle自帶工具;需要下載安裝才能使用。

4.1 sqludr安裝

?
1
2
3
4
[oracle@oracle235 ~]$ unzip sqluldr2linux64.zip
Archive: sqluldr2linux64.zip
 inflating: sqluldr2linux64.bin  
[oracle@oracle235 ~]$ mv sqluldr2linux64.bin $ORACLE_HOME/bin/sqludr

4.2 查看sqludr幫助

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[oracle@oracle235 ~]$ sqludr -?
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
 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

4.3 執(zhí)行sqludr

?
1
2
3
4
[oracle@oracle235 ~]$ sqludr lottu/li0924 query="tbl_load_01" file=lottu01.txt field=","
      0 rows exported at 2018-08-13 23:47:55, size 0 MB.
    1000 rows exported at 2018-08-13 23:47:55, size 0 MB.
     output file lottu01.txt closed at 1000 rows, size 0 MB.

總結(jié)

以上所述是小編給大家介紹的Oracle數(shù)據(jù)加載和卸載的實現(xiàn)方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對服務(wù)器之家網(wǎng)站的支持!

原文鏈接:https://www.cnblogs.com/lottu/archive/2018/08/27/9541300.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 中文字幕在线亚洲精品 | 日韩视频www| 欧美精品一区二区三区在线播放 | 精品国产91久久久久 | 亚洲一区二区三区四区精品 | 欧美曾交 | 三级18视频 | 欧美jizzhd极品欧美 | 日本一区二区视频在线观看 | 国产在线观看一区二区三区 | 天天操综 | xxxx18韩国护士hd老师 | 欧美成人三级视频 | 国产精品久久久久网站 | 欧美激情精品久久久久久黑人 | 精品成人久久久 | 中文字幕涩涩久久乱小说 | 在线免费亚洲 | 香蕉国产片| 中文字幕在线观看成人 | 午夜精品老牛av一区二区三区 | 国产精品剧情一区二区三区 | 国产成人av在线播放 | 亚洲黑人在线观看 | 一区二区三区日韩在线 | 亚洲综人网 | 欧美日韩手机在线观看 | 极品xxxx欧美一区二区 | 精品一区二区三区欧美 | 欧美精品成人 | 免费黄色在线电影 | 久久tv免费国产高清 | 久久综合综合久久 | 国产 一区 | 成人在线第一页 | 少妇av片| 法国性xxx精品hd| chengrenyingshi | 国产精品久久久久无码av | 免费国产wwwwwww网站 | 国产精品视频一区二区三区四区五区 |