中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

使用SQL*Loader導入CLOB和BLOB數據使用案例

發布時間:2020-08-07 16:06:13 來源:ITPUB博客 閱讀:319 作者:迷倪小魏 欄目:關系型數據庫

        在之前的四篇文章中,介紹了SQL*Loader的使用方法及使用案例,本篇使用SQL*Loader導入CLOBBLOB數據
      Oracle SQL*Loader使用案例(一)
      Oracle SQL*Loader使用案例(二)
      Oracle SQL*Loader使用案例(三)
      Oracle SQL*Loader使用案例(四)


      在使用SQL*Loader往數據庫中導入blobclob數據總令人有些頭疼。本文詳細記錄了用OracleSQL*Loader實現該功能的一個實驗案例,希望能對大家有幫助。

 

 

首先創建一張用于實驗的測試表

 

SCOTT@seiang11g>create table tb_clob(new_id number(20),new_to varchar2(100),new_subject varchar2(100),new_date date,new_content clob);
Table created.

 

下面是數據文件中的內容:

[oracle@wjq SQL*Loader]$ vim wjq_clob.csv
1,wjq123@qq.com,"Greeting from Mars",2017-11-02 10:59:43,\/u01\/app\/oracle\/SQL*Loader\/new_clob001.dat
2,seiang@126.com,"Special discount",2017-11-02 11:28:55,\/u01\/app\/oracle\/SQL*Loader\/new_clob002.dat
(特別注意:一定要注意數據文件的格式,不能有多余的空格存在,作者在這里栽過好多次的坑,否則導入的時候會報錯,所以執行導入之后最好查看一下日志信息)

 

new_content是消息正文,用clob數據類型表示。在數據文件中該字段僅保存每條記錄的消息正文的clob文件名。new_clob001.dat,new_clob002.dat文件中保存new_content的真正內容。

 

new_clob001.dat文件中的內容:

[oracle@wjq SQL*Loader]$ cat new_clob001.dat
China's top judicial authorities presented long-anticipated reports on Wednesday to national legislators on their progress in upholding the law and preventing wrongful convictions in the wake of important judicial reforms in 2013.

The Supreme People's Court and Supreme People's Procuratorate both submitted reports to the bimonthly session of the Standing Committee of the National People's Congress on Wednesday.The top court said it had overturned 37 wrongful convictions since November 2012, including in the high-profile case of Nie Shubin, who was exonerated on Dec 2, 2016, more than two decades after he was wrongly executed for rape and murder.

 

new_clob001.dat文件中的內容:

[oracle@wjq SQL*Loader]$ cat new_clob002.dat  
Thanks to these efforts, courts acquitted 4,032 defendants in accordance with the law between 2013 and September this year, the report said.

Courts have also been ordered to strictly exclude evidence obtained illegally, including evidence gained by torture, "and not to force anyone to plead guilty", Zhou said.In Shanghai, for example, between July 2016 and September this year, the city's courts received 24 applications from defense attorneys to strike evidence suspected to have been obtained illegally, leading to 15 reviews on the legality of evidence, he said.

 

導入上述的數據需要寫如下的控制文件:

[oracle@wjq SQL*Loader]$ cat wjq_clob.ctl
LOAD DATA  
INFILE '/u01/app/oracle/SQL*Loader/wjq_clob.csv' 
TRUNCATE INTO TABLE tb_clob 
FIELDS TERMINATED BY ',' 
( new_id       CHAR(20), 
  new_to       CHAR(100),   
  new_subject  CHAR(100), 
  new_date     DATE "YYYY-MM-DD HH24:MI:SS" ":new_date",
  clob_filename FILLER CHAR(1000000), 
  new_content  LOBFILE(clob_filename) TERMINATED BY EOF 
)

上述控制文件的關鍵在于定義一個clob_filename的偽字段(SQL*Loader中就是filler)以獲取clob文件名,緊接著用lobfile從該文件導入消息正文。如果需要導入blob類型的數據,其方法完全一樣。

 

下面就開始執行導入操作:

[oracle@wjq ~]$ sqlldr scott/tiger control=/u01/app/oracle/SQL*Loader/wjq_clob.ctl log=/u01/app/oracle/SQL*Loader/wjq_clob.log

SQL*Loader: Release 11.2.0.4.0 - Production on Thu Nov 2 11:43:54 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Commit point reached - logical record count 1
Commit point reached - logical record count 2

 

下面查看一下日志信息:

Table TB_CLOB:
  2 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  0 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null.

Space allocated for bind array:                1000488 bytes(1 rows)
Read   buffer bytes: 1048576

Total logical records skipped:          0
Total logical records read:             2
Total logical records rejected:         0
Total logical records discarded:        0

Run began on Thu Nov 02 11:43:54 2017
Run ended on Thu Nov 02 11:43:54 2017

Elapsed time was:     00:00:00.05
CPU time was:         00:00:00.00

 

通過日志可以看到,導入成功,下面通過查詢表中的內容來進行驗證

使用SQL*Loader導入CLOB和BLOB數據使用案例



作者:SEian.G(苦練七十二變,笑對八十一難)

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

正镶白旗| 杂多县| 三穗县| 申扎县| 新巴尔虎左旗| 合江县| 南雄市| 六安市| 太康县| 江源县| 鲁甸县| 政和县| 顺义区| 青浦区| 高州市| 班玛县| 乌拉特前旗| 洛川县| 怀安县| 洞头县| 晋宁县| 大化| 方山县| 铁岭县| 永丰县| 高要市| 信宜市| 永城市| 福鼎市| 峨边| 鲁甸县| 达孜县| 祁阳县| 瓦房店市| 湾仔区| 扎囊县| 张家界市| 上杭县| 泽库县| 利辛县| 青川县|