Chinaunix首页 | 论坛 | 博客
  • 博客访问: 598182
  • 博文数量: 825
  • 博客积分: 5000
  • 博客等级: 大校
  • 技术积分: 4980
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-27 14:19
文章分类

全部博文(825)

文章存档

2011年(1)

2008年(824)

我的朋友

分类:

2008-10-27 14:28:57

环境:
    源: windows 2003, oracle 10202 
    目标:windows 2000, oracle 10203 

    注:本文中所说的 schema 和 user 是一个意思。 

    impdp 的数据源既可以是expdp 导出来的DMP文件,也可以是一数据库,通过network_link 参数来指定数据源,schemas 参数说明要复制的用户,remap_schemas 参数说明源用户与目标用户的匹配关系,remap_tablepace 来调整原 schemas 使用的表空间与目标数据库用户要表空间的对应关系。这样,基本上可以把源schema的数据导入到目标数据库。格式如下:

    2、impdp user/password parfile=parfile.log

    **********parfile.log 的内容***************

    network_link=目标数据库上的数据库链。
    schema=源数据库上导出数据的用户。 
    remap_schema=源用户:目标用户。 
    remap_tablespace=源用户使用的表空间:目标用户将使用的表空间(包括临时表空间)。 

    **********parfile.log 的内容*************** 

    过程举例: 

    1、在目标数据库上创建数据库链,指向源数据库,数据库链中连接的用户必须具备EXP_FULL_DATABASE
角色的权限。 例: 

    A、新建数据库链里的用户,授予create session 和使用users 空间的权限,
SQL> create user link identified by "1"; 

    用户已创建。 

    SQL> grant create session to link; 

    授权成功。 

    SQL> ALTER USER LINK QUOTA UNLIMITED ON USERS; 

    用户已更改。 

    B、为该用户创建一表,用于复制用户过程。 
    SQL> CREATE TABLE LINK.DOC_TYPE AS SELECT * FROM INFO.DOC_TYPE; 

    表已创建。 

    SQL> SELECT TABLE_NAME FROM DBA_TABLES WHERE OWNER='LINK'; 

    TABLE_NAME 
    ------------------------------ 
    DOC_TYPE 

    C、使用该用户来创建数据库链。 
    SQL> create public database link tolink connect to link identified by "1" using '37ZHS'; 

    数据库链接已创建。 

    D、使用该链来复制link用户,报 ORA-39149: cannot link privileged user to non-privileged user
错误。 

    d:\oracle\product\10.2.0\db_1\BIN>impdp network_link=tolink schemas=link remap_schema=link:link2 

    Import: Release 10.2.0.2.0 - Production on Wednesday, 07 March, 2007 16:51:37 

    Copyright (c) 2003, 2005, . All rights reserved. 

    Username: / as sysdba 

    Connected to: Database 10g Enterprise Edition Release 10.2.0.2.0 - Production 
    With the Partitioning, OLAP and Data Mining options 
    ORA-31631: privileges are required 
    ORA-39149: cannot link privileged user to non-privileged user

    F、授予 exp_ful_database 权限后,复制成功。 

    SQL> grant exp_full_database to link; 
    授权成功。 

    d:\oracle\product\10.2.0\db_1\BIN>impdp network_link=tolink schemas=link remap_schema=link:link2 

    Import: Release 10.2.0.2.0 - Production on Wednesday, 07 March, 2007 16:54:30 

    Copyright (c) 2003, 2005, Oracle. All rights reserved. 

    Username: / as sysdba 

    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production 
    With the Partitioning, OLAP and Data Mining options 
    FLASHBACK automatically enabled to preserve database integrity. 
    Starting "SYS"."SYS_IMPORT_SCHEMA_01": /******** AS SYSDBA network_link=tolink schemas=link remap
_schema=link:link2 
    Estimate in progress using BLOCKS method... 
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA 
    Total estimation using BLOCKS method: 64 KB 
    Processing object type SCHEMA_EXPORT/USER 
    Processing object type SCHEMA_EXPORT/SYSTEM_GRANT 
    Processing object type SCHEMA_EXPORT/ROLE_GRANT 
    Processing object type SCHEMA_EXPORT/DEFAULT_ROLE 
    Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA 
    Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA 
    Processing object type SCHEMA_EXPORT/TABLE/TABLE 
    . . imported "LINK2"."DOC_TYPE" 8 rows 
    Job "SYS"."SYS_IMPORT_SCHEMA_01" successfully completed at 16:54:52 

[1]  

【责编:Peng】

--------------------next---------------------

阅读(352) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~