今天在写一个简单的备份脚本时,遇到了一个小问题。
在用IMPDP执行导入操作时报没有该用户。
奇怪明明建立了,怎么还会没有呢?这是突然想起来在IMPDP的参数SCHEMAS指定的比较“别扭”,因为原来在使用IMP的时候在SCHEMA级别时常常需要写FROMUSER 、TOUSER这两个参数的。但是IMPDP却没有!正好这次IMPDP导入的用户名和源用户又不同!
还好使用另外的REMAP_SCHEMA参数解决了该问题。ORACLE的官方手册中这样提到:
要注意:
1.该参数的使用方法 REMAP_SCHEMA=source_schema:target_schema
2.即使你指定的对应SCHEMA不存在,只要导入时连接的用户有足够的权限,就会使用DUMP文件中的CREATE USER的metadata来创建一个对应的用户的。
----------手册真的很重要 -:)
在用IMPDP执行导入操作时报没有该用户。
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: invalid operation
ORA-39165: Schema XXX was not found.
With the Partitioning, OLAP and Data Mining options
ORA-39002: invalid operation
ORA-39165: Schema XXX was not found.
奇怪明明建立了,怎么还会没有呢?这是突然想起来在IMPDP的参数SCHEMAS指定的比较“别扭”,因为原来在使用IMP的时候在SCHEMA级别时常常需要写FROMUSER 、TOUSER这两个参数的。但是IMPDP却没有!正好这次IMPDP导入的用户名和源用户又不同!
还好使用另外的REMAP_SCHEMA参数解决了该问题。ORACLE的官方手册中这样提到:
REMAP_SCHEMA
Default: none
Purpose
Loads all objects from the source schema into a target schema.
Syntax and Description
REMAP_SCHEMA=source_schema:target_schema
Multiple REMAP_SCHEMA lines can be specified, but the source schema must be different for each one. However, different source schemas can map to the same target schema. The mapping may not be 100 percent complete, because there are certain schema references that Import is not capable of finding. For example, Import will not find schema references embedded within the body of definitions of types, views, procedures, and packages.
If the schema you are remapping to does not already exist, the import operation creates it, provided the dump file set contains the necessary CREATE USER metadata for the source schema and you are importing with enough privileges.
Default: none
Purpose
Loads all objects from the source schema into a target schema.
Syntax and Description
REMAP_SCHEMA=source_schema:target_schema
Multiple REMAP_SCHEMA lines can be specified, but the source schema must be different for each one. However, different source schemas can map to the same target schema. The mapping may not be 100 percent complete, because there are certain schema references that Import is not capable of finding. For example, Import will not find schema references embedded within the body of definitions of types, views, procedures, and packages.
If the schema you are remapping to does not already exist, the import operation creates it, provided the dump file set contains the necessary CREATE USER metadata for the source schema and you are importing with enough privileges.
要注意:
1.该参数的使用方法 REMAP_SCHEMA=source_schema:target_schema
2.即使你指定的对应SCHEMA不存在,只要导入时连接的用户有足够的权限,就会使用DUMP文件中的CREATE USER的metadata来创建一个对应的用户的。
----------手册真的很重要 -:)