在鎖表情況下expdp匯出資料
在使用expdp匯出應用表資料時,有時會有這種期望:該表在準備匯出時資料就不會被修改,直到匯出結束。針對這種情況,一般會在匯出前對需要匯出的表加鎖,保證資料不能被修改。那麼什麼鎖可以滿足這種情況呢?沒錯,share鎖:
SQL>lock table linc.CRITIC in share mode;
該會話不要退出。另開一視窗執行expdp匯出表操作,執行好後,該會話關閉事務。
SQL>rollback;
share mode可以允許別的會話select或select for update以及lock table table_name in share mode,不允許insert/update/delete。
那麼排他鎖可以嗎?答案是不行的,測試如下:
SQL> lock table linc.CRITIC in exclusive mode;
Table(s) Locked.
如果這時候你要匯出資料,expdp會開始等待。
SQL> select sid,username,program,event,sql_id from v$session where username is not null;
SID USERN PROGRAM EVENT SQL_ID
---------- ----- ------------------------------ -------------------------------------------------- -------------
846 LINC oracle@ibmvs_a (DM00) wait for unread message on broadcast channel
845 LINC ude@ibmvs_a (TNS V1-V3) wait for unread message on broadcast channel 7wn3wubg7gjds
840 LINC oracle@ibmvs_a (DW01) enq: TM - contention
836 SYS sqlplus@ibmvs_a (TNS V1-V3) SQL*Net message to client 8779q92b78vg0
848 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
849 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
851 LINC olcp@ibmvs_a (TNS V1-V3) SQL*Net message from client
852 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
854 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
856 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
857 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
859 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
864 SYS sqlplus@ibmvs_a (TNS V1-V3) SQL*Net message from client
837 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
834 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
874 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
822 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
832 LINC HTDB@ibmvs_a (TNS V1-V3) SQL*Net message from client
18 rows selected.
SQL> select sql_text from v$sql where sql_id='7wn3wubg7gjds';
SQL_TEXT
----------------------------------------------------------------------------------------------------
BEGIN :1 := sys.kupc$que_int.get_status(:2, :3); END;
原因是expdp在開始匯出表資料時,會先對錶進行lock。很顯然該操作會失敗。
那麼把表空間設定為read only可以嗎?
alter tablespace datatb read only;
oracle@ibmvs_a@/other/dumpdir $ expdp test/test dumpfile=t.dmp logfile=t.log tables=test.t directory=dumpdir
Export: Release 10.2.0.3.0 - 64bit Production on Monday, 23 May, 2011 11:31:14
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
ORA-31626: job does not exist
ORA-31633: unable to create master table "TEST.SYS_EXPORT_TABLE_05"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT", line 863
ORA-01647: tablespace 'DATATB' is read only, cannot allocate space in it
此時我們發現,expdp直接報錯:
unable to create master table "TEST.SYS_EXPORT_TABLE_05
原來expdp匯出時會建立master table,該表空間被我們置為read only狀態,自然該操作會失敗。
恢復表空間為可讀可寫狀態:
alter tablespace datatb read write;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28371090/viewspace-1664841/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle資料泵匯出匯入(expdp/impdp)Oracle
- expdp在匯出時對資料大小進行評估
- Oracle expdp資料泵遠端匯出Oracle
- Oracle使用資料泵expdp,impdp進行資料匯出匯入Oracle
- oracle按照表條件expdp匯出資料Oracle
- 【資料泵】EXPDP匯出表結構(真實案例)
- expdp 匯出時指定節點
- expdp匯出報錯ORA-39127
- 使用Exp和Expdp匯出資料的效能對比與最佳化
- oracle10g expdp資料泵的bug,按schema匯出,匯入impdp時無jobOracle
- Oracle 12c expdp和impdp匯出匯入表Oracle
- 基於flashback_scn的expdp匯出
- Oracle 12.1.0.2 expdp匯出分割槽表資料遇到BUG慢的原因和解決方法Oracle
- [oracle] expdp 匯出分割槽表的分割槽Oracle
- 資料庫 MySQL 資料匯入匯出資料庫MySql
- ORACLE expdp在表空間較多的情況下執行非常緩慢Oracle
- sqoop資料匯入匯出OOP
- Oracle 資料匯入匯出Oracle
- 資料泵匯出匯入
- Oracle資料匯入匯出Oracle
- phpMyAdmin匯入/匯出資料PHP
- Magicodes.IE 在100萬資料量下匯入匯出效能測試
- oracle 11g expdp匯出報ORA-24001Oracle
- [重慶思莊每日技術分享]-expdp導資料時評估匯出檔案大小
- 請在這幾種情況下匯入TPM管理
- mysql匯出資料MySql
- 如何確定一個dmp檔案是exp匯出的還是expdp匯出的?
- 資料泵expdp匯出遇到ORA-01555和ORA-22924問題的分析和處理
- Oracle 11g 透過expdp按日期匯出表Oracle
- Spring JPA聯表情況下的複雜查詢Spring
- Oracle資料庫——資料匯出時出現匯出成功終止, 但出現警告。Oracle資料庫
- Mongodb資料的匯出與匯入MongoDB
- oracle資料匯出匯入(exp/imp)Oracle
- 匯入和匯出AWR的資料
- EasyPoi, Excel資料的匯入匯出Excel
- Mysql 資料庫匯入與匯出MySql資料庫
- 匯出百萬級資料
- MySQL資料的匯出MySql
- layui 資料表格匯出UI