資料泵對已經存在的表載入索引 imp 和impdp
這裡探討了使用imp 和impdp對含有索引的表的匯入的一點差別。
使用imp可以在表存在的情況下,不刪除表,且匯入表的資料和索引。
1)建立實驗表cust(已存在)
SQL> conn scott/yang
已連線。
SQL> select * from cust;
ID CUTNAME
---------- ----------
1 JANE
2 Jone
3 TOM
4 yang
5 yangyi
6 xiaonan
已選擇6行。
SQL> create index indcust_id on cust(id);
索引已建立。
2)匯出表
HOST exp scott/yang file=cust.dmp tables=cust
連線到: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已匯出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即將匯出指定的表透過常規路徑...
. . 正在匯出表 CUST匯出了 6 行
成功終止匯出, 沒有出現警告。
SQL> drop index indcust_id;
索引已刪除
3)使用imp匯入表
SQL> HOST imp scott/yang file=cust.dmp tables=cust ignore=y
連線到: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
經由常規路徑由 EXPORT:V11.01.00 建立的匯出檔案
已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
. 正在將 SCOTT 的物件匯入到 SCOTT
. 正在將 SCOTT 的物件匯入到 SCOTT
. . 正在匯入表 "CUST"匯入了 6 行
成功終止匯入, 沒有出現警告。
SQL> select * from cust;
ID CUTNAME
---------- ----------
1 JANE
2 Jone
3 TOM
4 yang
5 yangyi
6 xiaonan
1 JANE
2 Jone
3 TOM
4 yang
5 yangyi
6 xiaonan
已選擇12行。
SQL> select index_name from user_indexes
2 where table_name='CUST';
INDEX_NAME
------------------------------
INDCUST_ID
4)impdp的預設工作並非如此,監測到表存在時,impdp會跳過索引的建立
SQL> create table texp(id number,name varchar2(30));
表已建立。
SQL> insert into texp
2 select rownum,tname
3 from tab;
已建立9行。
SQL> commit;
提交完成。
SQL> create index indtexp_id on texp (id);
索引已建立。
5)匯出表
expdp scott/yang directory=dump dumpfile=scottexp.dp tables=texp
連線到: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
啟動 "SCOTT"."SYS_EXPORT_TABLE_01": scott/******** directory=dump dumpfile=scotttexp.dmp tables=texp
正在使用 BLOCKS 方法進行估計...
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的總估計: 64 KB
處理物件型別 TABLE_EXPORT/TABLE/TABLE
處理物件型別 TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
. . 匯出了 "SCOTT"."TEXP" 5.507 KB 9 行
已成功載入/解除安裝了主表 "SCOTT"."SYS_EXPORT_TABLE_01"
******************************************************************************
SCOTT.SYS_EXPORT_TABLE_01 的轉儲檔案集為:
F:\DUMP\SCOTTTEXP.DMP
作業 "SCOTT"."SYS_EXPORT_TABLE_01" 已於 23:29:38 成功完成
清除資料,並刪除索引:
SQL> drop index indtexp_id;
索引已刪除。
SQL> truncate table texp;
表被截斷。
6)然後再匯入表
impdp scott/yang directory=dump dumpfile=scottexp.dp tables=texp
SQL> select count(*) from texp;
COUNT(*)
----------
9
SQL> select index_name from user_indexes
2 where table_name='TEXP';
未選定行
資料雖然匯入了,但是索引沒有建立。不過要解決這個問題也很簡單,透過INCLUDE就可以解決這個問題:
SQL> truncate table texp;
表被截斷。
impdp scott/yang directory=dump dumpfile=scottexp.dp tables=texp table_exists_action=truncate include=index
連線到: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功載入/解除安裝了主表 "SCOTT"."SYS_IMPORT_TABLE_01"
啟動 "SCOTT"."SYS_IMPORT_TABLE_01": scott/******** directory=dump dumpfile=scotttexp.dmp tables=texp table_exists_action=truncate include=index
處理物件型別 TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
作業 "SCOTT"."SYS_IMPORT_TABLE_01" 已於 23:35:39 成功完成
SQL> select count(*) from texp;
COUNT(*)
----------
0
SQL> select index_name from user_indexes
2 where table_name='TEXP';
INDEX_NAME
------------------------------
INDTEXP_ID
SQL> drop index indtexp_id;
索引已刪除。
impdp scott/yangdirectory=dump dumpfile=scotttexp.dmp tables=texp table_exists_action=truncate include=index include=table_data
連線到: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功載入/解除安裝了主表 "SCOTT"."SYS_IMPORT_TABLE_01"
啟動 "SCOTT"."SYS_IMPORT_TABLE_01": scott/******** directory=dump dumpfile=scotttexp.dmp tables=texp table_exists_action=truncate include=index include=table_data
處理物件型別 TABLE_EXPORT/TABLE/TABLE_DATA
. . 匯入了 "SCOTT"."TEXP" 5.507 KB 9 行
處理物件型別 TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件型別 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
作業 "SCOTT"."SYS_IMPORT_TABLE_01" 已於 23:37:57 成功完成
最後檢查一下是否成功
SQL> select count(*) from texp;
COUNT(*)
----------
9
SQL> select index_name from user_indexes
2 where table_name='TEXP';
INDEX_NAME
------------------------------
INDTEXP_ID
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-664400/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 資料泵對已經存在的表載入索引索引
- Impdp資料泵匯入
- 使用資料泵impdp匯入資料
- 資料泵IMPDP 匯入工具的使用
- EXPDP 和 IMPDP 資料泵的使用_1
- EXPDP 和 IMPDP 資料泵的使用_2
- 資料泵 impdp 操作
- 資料泵匯入-在物件已存在的情況下執行匯入物件
- 【原創】比較資料泵和exp/imp對相同資料匯出/匯入的效能差異
- 10G資料泵載入命令expdp/impdp的引數說明
- Oracle資料泵匯出匯入(expdp/impdp)Oracle
- 物件及資料存在時的資料匯入(imp)物件
- oracl11g下exp_imp匯入已經存在表或其它物件的使用者物件
- 資料庫泵(expdp/impdp)匯入匯出流程資料庫
- 針對資料泵匯出 (expdp) 和匯入 (impdp)工具效能降低問題的檢查表
- 資料泵基礎(impdp/expdp)
- Oracle使用資料泵expdp,impdp進行資料匯出匯入Oracle
- SmartSVN開啟已經存在的資料夾
- 【IMPDP】當匯入資料時遭遇表已存時的應對手段——TABLE_EXISTS_ACTION引數
- 資料泵匯出匯入表
- 【impdp】IMPDP中的TRANSFORM引數--【資料泵】EXPDP匯出表結構(真實案例)後傳ORM
- expdp impdp Data Pump(資料泵)使用解析
- truncate表後impdp匯入該表時加exclude=index引數並不能排除索引資料的匯入Index索引
- EXP/IMP和EXPDP/IMPDP的區別
- 使用資料泵(expdp、impdp)遷移資料庫流程資料庫
- 【impdp】資料泵impdp工具選項詳解及應用示例
- 按計劃瞭解資料泵expdp/impdp
- 資料泵(expdp,impdp)高版本匯入低版本操作例項
- 使用impdp,expdp資料泵進入海量資料遷移
- 用impdp匯入資料的一次經歷
- EXP COMPRESS以及EXP/IMP EXPDP/IMPDP匯入表結構注意
- Oracle資料泵的匯入和匯出Oracle
- Oracle使用資料泵匯出匯入表Oracle
- 使用IMP將資料匯入指定的表空間
- 把一個已存在資料的大表改成分割槽表
- Oracle使用資料泵 (expdp/impdp)實施遷移Oracle
- 關於資料泵impdp引數驗證(一)
- 10g 資料泵(Data Dump) -- EXPDP & IMPDP [zt]