Oracle的11gr2版本中,並沒有對資料泵做出多大的改動,主要是增加了對原始版本參數的支援,並且去掉了一些小的限制。
這一篇介紹資料泵對版本的支援。
在11.2中,Oracle增加了版本的功能,而資料泵也支援對指定版本的匯出,或將對象匯入到指定的版本中。
SQL> conn yangtk/yangtk
已串連。
SQL> select sys_context('USERENV', 'CURRENT_EDITION_NAME') from dual;
SYS_CONTEXT('USERENV','CURRENT_EDITION_NAME')
-----------------------------------------------------------------------
ORA$BASE
SQL> select synonym_name
2 from user_synonyms;
SYNONYM_NAME
------------------------------
S_1
SQL> create edition my_edition;
版本已建立。
SQL> alter session set edition = my_edition;
會話已更改。
SQL> create synonym s_my_edition for t;
同義字已建立。
SQL> host
[oracle@bjtest ~]$ expdp yangtk/yangtk directory=d_output dumpfile=my_edition.dp include=synonym source_edition=my_edition
Export: Release11.2.0.1.0 - Production on星期一9月14 08:10:53 2009
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
串連到: Oracle Database11gEnterprise Edition Release11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
啟動"YANGTK"."SYS_EXPORT_SCHEMA_01": yangtk/******** directory=d_output dumpfile=my_edition.dp include=synonym source_edition=my_edition
正在使用BLOCKS方法進行估計...
處理物件類型SCHEMA_EXPORT/TABLE/TABLE_DATA
使用BLOCKS方法的總估計: 0 KB
處理物件類型SCHEMA_EXPORT/SYNONYM/SYNONYM
本文URL地址:http://www.bianceng.cn/database/Oracle/201410/45402.htm
已成功載入/卸載了主表"YANGTK"."SYS_EXPORT_SCHEMA_01"
******************************************************************************
YANGTK.SYS_EXPORT_SCHEMA_01的轉儲檔案集為:
/home/oracle/my_edition.dp
作業"YANGTK"."SYS_EXPORT_SCHEMA_01"已於08:11:02成功完成
[oracle@bjtest ~]$ impdp yangtk/yangtk directory=d_output dumpfile=my_edition.dp target_edition=ora\$base
Import: Release11.2.0.1.0 - Production on星期一9月14 08:13:08 2009
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
串連到: Oracle Database11gEnterprise Edition Release11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功載入/卸載了主表"YANGTK"."SYS_IMPORT_FULL_01"
啟動"YANGTK"."SYS_IMPORT_FULL_01": yangtk/******** directory=d_output dumpfile=my_edition.dp target_edition=ora$base
處理物件類型SCHEMA_EXPORT/SYNONYM/SYNONYM
ORA-31684:物件類型SYNONYM:"YANGTK"."S_1"已存在
作業"YANGTK"."SYS_IMPORT_FULL_01"已經完成,但是有1個錯誤(於08:13:11完成)
[oracle@bjtest ~]$ exit
exit
SQL> select synonym_name
2 from user_synonyms;
SYNONYM_NAME
------------------------------
S_1
S_MY_EDITION
由於版本MY_EDITION是ORA$BASE的子版本,因此可以看到父版本建立的同義字。匯出MY_EDITION版本的同義字時,匯出了S_1和S_MY_EDITION兩個對象。
而匯入到目標版本ORA$BASE時,由於S_1已經存在,因此只將同義字S_MY_EDITION匯入到目標版本中。
資料泵的匯出和匯入版本功能,只是指定了匯出或匯入的版本對象,而在資料泵儲存的檔案中並沒有儲存版本對應的資訊,因此在匯入的時候,如果沒有指定TARGET_EDITION,則Oracle就會匯入到預設版本下,而和匯出時指定的版本沒有關係。
作者:51cto部落格 Oracle小混子