包含觸發器的LOB表執行IMP導致EMPTY_LOB變為空
如果一個表包含了觸發器,在透過IMP匯入資料的時候,原本的EMPTY_LOB將被轉化為NULL,以提高IMP的效率。
Oracle 10以後的版本都存在這個現象:
SQL> create table t_lob (id number, content clob);
Table created.
SQL> insert into t_lob values (1, empty_clob());
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t_lob where content is null;
no rows selected
下面透過exp和expdp匯出表:
[oracle@yans1 ~]$ exp test/test file=t_lob.dmp tables=t_lob
Export: Release 10.2.0.3.0 - Production on 星期六 12月 19 22:48:48 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table T_LOB 1 rows exported
Export terminated successfully without warnings.
[oracle@yans1 ~]$ expdp test/test directory=d_output dumpfile=t_lob.dp tables=t_lob
Export: Release 10.2.0.3.0 - 64bit Production on 星期六, 19 12月, 2009 22:49:07
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Starting "TEST"."SYS_EXPORT_TABLE_01": test/******** directory=d_output dumpfile=t_lob.dp tables=t_lob
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 256 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "TEST"."T_LOB" 5.257 KB 1 rows
Master table "TEST"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for TEST.SYS_EXPORT_TABLE_01 is:
/home/oracle/t_lob.dp
Job "TEST"."SYS_EXPORT_TABLE_01" successfully completed at 22:49:36
下面刪除T_LOB表:
SQL> drop table t_lob purge;
Table dropped.
利用IMP匯入:
[oracle@yans1 ~]$ imp test/test file=t_lob.dmp full=y
Import: Release 10.2.0.3.0 - Production on 星期六 12月 19 22:50:20 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing TEST's objects into TEST
. importing TEST's objects into TEST
. . importing table "T_LOB" 1 rows imported
Import terminated successfully without warnings.
檢查匯入的LOB列是否為空:
SQL> select * from t_lob where content is null;
no rows selected
下面再次刪除T_LOB表:
SQL> drop table t_lob purge;
Table dropped.
利用IMPDP匯入:
[oracle@yans1 ~]$ impdp test/test directory=d_output dumpfile=t_lob.dp
Import: Release 10.2.0.3.0 - 64bit Production on 星期六, 19 12月, 2009 22:51:26
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Master table "TEST"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "TEST"."SYS_IMPORT_FULL_01": test/******** directory=d_output dumpfile=t_lob.dp
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "TEST"."T_LOB" 5.257 KB 1 rows
Job "TEST"."SYS_IMPORT_FULL_01" successfully completed at 22:51:28
檢查匯入的LOB列是否為空:
SQL> select * from t_lob where content is null;
no rows selected
可以看到,無論是IMP還是IMPDP,在沒有觸發器的情況下,匯入的都是EMPTY_LOB,而不是NULL,下面新增一個觸發器:
SQL> create trigger t_lob
2 before insert on t_lob
3 for each row
4 begin
5 null;
6 end;
7 /
Trigger created.
SQL> delete t_lob;
1 row deleted.
SQL> commit;
Commit complete.
透過IMP執行匯入,設定IGNORE=Y:
[oracle@yans1 ~]$ imp test/test file=t_lob.dmp full=y ignore=y
Import: Release 10.2.0.3.0 - Production on 星期六 12月 19 23:34:34 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing TEST's objects into TEST
. importing TEST's objects into TEST
. . importing table "T_LOB" 1 rows imported
Import terminated successfully without warnings.
檢查匯入的LOB內容:
SQL> select * from t_lob where content is null;
ID CONTENT
---------- --------------------------------------------------------------------------------
1
顯然IMP將EMPTY_LOB轉變為NULL了。
下面看看資料泵的匯入是否存在同樣的問題:
SQL> delete t_lob;
1 row deleted.
利用IMPDP匯入資料:
[oracle@yans1 ~]$ impdp test/test directory=d_output dumpfile=t_lob.dp content=data_only
Import: Release 10.2.0.3.0 - 64bit Production on 星期六, 19 12月, 2009 23:54:56
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Master table "TEST"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "TEST"."SYS_IMPORT_FULL_01": test/******** directory=d_output dumpfile=t_lob.dp content=data_only
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "TEST"."T_LOB" 5.257 KB 1 rows
Job "TEST"."SYS_IMPORT_FULL_01" successfully completed at 23:55:00
檢查匯入的LOB資料是否為空:
SQL> select * from t_lob where content is null;
no rows selected
顯然這個問題只是IMP會出現。顯然,EMPTY_LOB和NULL還是有區別的,如果程式訪問的時候認為二者是不同的狀態,那麼在使用IMP匯入LOB資料的時候要檢查表上是否存在觸發器,否則很可能導致表中原始的EMPTY_LOB變成NULL。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-623091/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- dbms_lob儲存過程導致臨時表空間100%儲存過程
- 記一次,因表變數導致SQL執行效率變慢變數SQL
- 行為和觸發器觸發器
- oracle 分割槽表move和包含分割槽表的lob moveOracle
- 一次因表變數導致SQL執行效率變慢的實戰記錄SNSR變數SQL
- wpf popup導致MouseLeftButtonUp無法觸發
- ADF 第四篇:管道的執行和觸發器觸發器
- Jenkins設定定時觸發器執行任務Jenkins觸發器
- pymysql 非執行緒安全導致的故障.MySql執行緒
- 禁止oracle表的觸發器triggerOracle觸發器
- React+Dav改變props不觸發componentWillReceiveProps導致頁面無法再次渲染React
- Oracle SYSAUX 表空間使用率100% 導致的DB 故障OracleUX
- Laravel5.5執行表遷移命令出現表為空的解決方案Laravel
- 因為CPU數變化導致執行sar命令報錯:Invalid system activity file: /var/log/sa/saxx
- OGG 表結構變化導致同步異常
- 執行緒崩潰為什麼不會導致 JVM 崩潰執行緒JVM
- HttpClient引發的執行緒數過多導致應用崩潰HTTPclient執行緒應用崩潰
- 表空間集自包含檢查
- Oracle目錄由於TFA觸發bug導致jdb檔案未自動清理引起空間不足Oracle
- 嚴重 PHP 漏洞導致伺服器遭受遠端程式碼執行PHP伺服器
- uni.$off 可能會移除過多的通知,導致通知不觸發
- OGG相關的CPATURE導致SYSAUX表空間異常暴增處理UX
- ORACLE 11.2.0.4 for HPUNIX 業務SQL處理資料量變化導致的CPU使用率超標觸發告警OracleSQL
- 【YashanDB知識庫】透過觸發器複製varchar(4000 char)列的資料導致亂碼觸發器
- 硬碟問題導致Gbase資料庫叢集SQL任務執行效率變慢硬碟資料庫SQL
- 動態建立 @ViewChild 導致執行時錯誤的原因分析View
- 記一次執行緒池配置導致的ThreadLocal清空執行緒thread
- 用exp、imp遷移包含物化檢視日誌的資料
- ajax非同步導致js方法順序執行不了非同步JS
- 執行SQL查詢導致磁碟耗盡故障演示SQL
- WebMagic多執行緒導致註解失效問題Web執行緒
- @Transactional 中使用執行緒鎖導致了鎖失效執行緒
- 使用Disql執行表空間還原的複雜用法SQL
- impdp導致主鍵索引的變化索引
- Discuz 6、7 版本存在全域性變數防禦繞過導致程式碼執行漏洞變數
- 系統變數group_replication_group_seeds為空導致MySQL節點無法啟動組複製變數MySql
- mysql 5.7 導致的行為改變. 效能優化的副產品 以及對應的解決方案MySql優化
- java 併發,為執行緒建立本地變數 ThreadLocal的使用Java執行緒變數thread
- 手動執行SQL觸發器id自增報錯處理方式SQL觸發器