Oracle 11G在用EXP 導出時,空表不能導出解決數據庫
(轉)(。http://wanwentao.blog.51cto.com/2406488/545154oracle
11G中有個新特性,當表無數據時,不分配segment,以節省空間blog
解決方法:get
一、insert一行,再rollback就產生segment了。io
該方法是在在空表中插入數據,再刪除,則產生segment。導出時則可導出空表。table
二、設置deferred_segment_creation 參數file
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 FALSEselect
該參數值默認是TRUE,當改成FALSE時,不管是空表仍是非空表,都分配segment。密碼
需注意的是:該值設置後對之前導入的空表不產生做用,仍不能導出,只能對後面新增的表產生做用。如需導出以前的空表,只能用第一種方法。方法
搞了我很久,最後查到這個方法。
先查詢一下當前用戶下的全部空表
select table_name from user_tables where NUM_ROWS=0;
用如下這句查找空表
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0
把查詢結果導出,執行導出的語句
'ALTERTABLE'||TABLE_NAME||'ALLOCATEEXTENT;'
-----------------------------------------------------------
alter table AQ$_AQ$_MEM_MC_H allocate extent;
alter table AQ$_AQ$_MEM_MC_G allocate extent;
alter table AQ$_AQ$_MEM_MC_I allocate extent;
alter table AQ$_AQ_PROP_TABLE_T allocate extent;
alter table AQ$_AQ_PROP_TABLE_H allocate extent;
alter table AQ$_AQ_PROP_TABLE_G allocate extent;
alter table AQ$_AQ_PROP_TABLE_I allocate extent;
alter table AQ$_KUPC$DATAPUMP_QUETAB_T allocate extent;
alter table AQ$_KUPC$DATAPUMP_QUETAB_H allocate extent;
alter table AQ$_KUPC$DATAPUMP_QUETAB_G allocate extent;
alter table AQ$_KUPC$DATAPUMP_QUETAB_I allocate extent;
'ALTERTABLE'||TABLE_NAME||'ALLOCATEEXTENT;'
-----------------------------------------------------------
alter table AQ$_SYS$SERVICE_METRICS_TAB_T allocate extent;
alter table AQ$_SYS$SERVICE_METRICS_TAB_H allocate extent;
alter table AQ$_SYS$SERVICE_METRICS_TAB_G allocate extent;
alter table AQ$_SYS$SERVICE_METRICS_TAB_I allocate extent;
而後再執行
exp 用戶名/密碼@數據庫名 file=/home/oracle/exp.dmp log=/home/oracle/exp_smsrun.log
成功!