Oracle 11G在用EXP 匯出時,空表不能匯出解決

來源:互聯網
上載者:User

標籤:form   init   deferred   節省空間的   產生   att   系統   sig   assign   

  • 一、問題原因:
    11G中有個新特性,當表無資料時,不分配segment,以節省空間的

    1、insert一行,再rollback就產生segment了。 該方法是在在空表中插入資料,再刪除,則產生segment。匯出時則可匯出空表。

    2、設定deferred_segment_creation 參數

    SQL> show parameter deferred_segment_creation

    NAME TYPE VALUE
    ------------------------------------ ----------- ----------
    deferred_segment_creation boolean TRUE

    SQL> alter system set deferred_segment_creation=false;

    系統已更改。

    SQL> show parameter deferred_segment_creation

    NAME TYPE VALUE

    ------------------------------------ ----------- ----------
    deferred_segment_creation boolean FALSE

    該參數值預設是TRUE,當改為FALSE時,無論是空表還是非空表,都分配segment。

    需注意的是:該值設定後對以前置入的空表不產生作用,仍不能匯出,只能對後面新增的表產生作用。如需匯出之前的空表,只能用第1種方法或者下面的解決方案。

  • 二、解決方案:

    1、先查詢一下目前使用者下的所有空表

    select table_name from user_tables where NUM_ROWS=0;

    2、用以下這句尋找空表

    select ‘alter table ‘||table_name||‘ allocate extent;‘ from user_tables where num_rows = 0 and table_name like ‘UFLO_%‘;

    把查詢結果匯出,執行匯出的語句

    ‘ALTERTABLE‘||TABLE_NAME||‘ALLOCATEEXTENT;‘

    -----------------------------------------------------------
    1 alter table UFLO_CALENDAR allocate extent;
    2 alter table UFLO_CALENDAR_DATE allocate extent;
    3 alter table UFLO_D_NODE_ATTRIBUTE allocate extent;
    4 alter table UFLO_D_NODE_ENTRY allocate extent;
    5 alter table UFLO_D_PROCESS_ATTRIBUTE allocate extent;
    6 alter table UFLO_D_PROCESS_ENTRY allocate extent;
    7 alter table UFLO_D_PROCESS_ENTRY_ASSIGNEE allocate extent;
    8 alter table UFLO_FORM allocate extent;
    9 alter table UFLO_TABLE_COLUMN allocate extent;
    10 alter table UFLO_TABLE_DEFINITION allocate extent;
    11 alter table UFLO_TASK_APPOINTOR allocate extent;
    12 alter table UFLO_TASK_REMINDER allocate extent;

    3、然後再執行

    exp 使用者名稱/密碼@資料庫名 file=/home/oracle/exp.dmp log=/home/oracle/exp_smsrun.log 成功!

==================================================================================================================

註:

1、使用ALLOCATE EXTENT的說明

使用ALLOCATE EXTENT可以為資料庫物件分配Extent。其文法如下:

-----------
ALLOCATE EXTENT { SIZE integer [K | M] | DATAFILE ‘filename‘ | INSTANCE integer }
-----------

可以針對資料表、索引、物化視圖等手工分配Extent。

ALLOCATE EXTENT使用範例:

ALLOCATE EXTENT
ALLOCATE EXTENT(SIZE integer [K | M])
ALLOCATE EXTENT(DATAFILE ‘filename‘)
ALLOCATE EXTENT(INSTANCE integer)
ALLOCATE EXTENT(SIZE integer [K | M] DATAFILE ‘filename‘)
ALLOCATE EXTENT(SIZE integer [K | M] INSTANCE integer)

針對資料表操作的完整文法如下:
-----------
ALTER TABLE [schema.]table_name ALLOCATE EXTENT [({ SIZE integer [K | M] | DATAFILE ‘filename‘ | INSTANCE integer})]
-----------

故,需要構建如下樣子簡單的SQL命令:

-----------
alter table aTabelName allocate extent
-----------

 

 

 

 

 

  • 採用expdp和impdp 就不會存在改問題

create directory expdp_dir as   ‘/data/app1/dp‘; 
grant read,write on directory expdp_dir to DRGN_OWNER; 


expdp DRGN_OWNER/DRGN_OWNER DIRECTORY=expdp_dir DUMPFILE=DRGN_OWNER.dmp SCHEMAS=DRGN_OWNER logfile=DRGN_OWNERexpdp.log 

create directory impdp_dir as ‘/data/app1/dp‘; 
grant read,write on directory impdp_dir to DRGN_OWNER; 

impdp DRGN_OWNER/DRGN_OWNER DIRECTORY=impdp_dir DUMPFILE=DRGN_OWNER.dmp logfile=DRGN_OWNER.dmpimpdp.log 

空表果然已經匯入了 

我個人建議,建立了空的資料庫後,馬上執行 
alter system set deferred_segment_creation=flase sscope=spfile; 
shutdowm immediate 
startup 

Oracle 11G在用EXP 匯出時,空表不能匯出解決

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.