SQL> create directory dpdump as '/oracle/oracle/admin/ecology/dpdump';    (创建导出的逻辑目录)
SQL> Grant read,write on directory dpdump to public;                       (授权)
SQL> select * from dba_directories ;                                       (查看逻辑目录)
[oracle@oa ~]$ expdp ecology/ecology@orcl directory=dpdump full=y dumpfile =expdp_test1.dmp    (导出数据库,包含空表,导出的文件名为expdp_test1.dmp,文件位置是逻辑目录的位置)

 


在同一台服务器上导入:
SQL> drop user ecology cascade;      (删除用户)
SQL> drop tablespace ecology including contents and datafiles;(删除表和数据)
SQL> create tablespace ecology datafile 'oracle\oracle\oradata\ecology.dbf' size 500m reuse autoextend on next 1024k maxsize unlimited extent management local uniform size 500K;               (创建表空间)
SQL> create user ecology identified by ecology default tablespace ecology temporary tablespace temp;   (创建表空间用户)
SQL> grant connect,resource,dba to ecology;            (授权)

[oracle@oatest ~]$ impdp ecology/ecology@ecology dumpfile =expdp_test1.dmp directory=dpdump     (导入)
测试服务器:
地址:202.200.2.187
安装目录:oracle     /oracle/oracle
         oa         /oa/weaver
         resin      /usr/resin-2.1.14
启动时先启动数据库
oracle用户   #lsnrctl start           启动数据库监听
           #lsnrctl stop            关闭数据库监听
 #sqlplus ’/as sysdba’
           SQL>startup              开启数据库
           SQL> shutdown immediate   关闭数据库
启动resin
root用户  #cd /usr/resin-2.1.14/bin   进入目录
          # . startresin
          

 

 

 


http://www.2cto.com/database/201111/111541.html
oracle11g用exp导出数据库的时候,空表是导不出来的,所以必须用数据泵导入导出oracle数据库。

 

1、expdp

 

SQL> create directory 目录名(如:dmpbx)as 存储地址(如:'/root/usr/……');

 

目录已创建。

 

SQL> grant read,write on directory 目录名to public;

 

授权成功。

 

SQL> exit

 

expdp 用户名1/密码@实例dumpfile=备份文件名(ecology.dmp)directory= 目录名(dmpbx)

 

2、impdp

 

SQL> create directory 目录名(如:dmpbx)as 存储地址(如:'/root/usr/……');

 

目录已创建。

 

SQL> grant read,write on directory 目录名to public;

 

授权成功。

 

SQL> exit

 

impdp 用户名2/密码@实例directory=目录名dumpfile=备份文件名.dmp logfile=日志名.log REMAP_SCHEMA=用户名1:用户名2

 

如果impdp是在同一台机器上操作的,则impdp前的创建目录和赋权的步骤都可以省略

 

 

参考文档   http://www.cnblogs.com/lanzi/archive/2011/01/06/1927731.html
数据泵文件
expdp介绍
EXPDP命令行选项
1. ATTACH
该选项用于在客户会话与已存在导出作用之间建立关联.语法如下
ATTACH=[schema_name.]job_name
Schema_name用于指定方案名,job_name用于指定导出作业名.注意,如果使用ATTACH选项,在命令行除了连接字符串和ATTACH选项外,不能指定任何其他选项,示例如下:
Expdp scott/tiger ATTACH=scott.export_job

2. CONTENT
该选项用于指定要导出的内容.默认值为ALL
CONTENT={ALL | DATA_ONLY | METADATA_ONLY}
当设置CONTENT为ALL时,将导出对象定义及其所有数据.为DATA_ONLY时,只导出对象数据,为METADATA_ONLY时,只导出对象定义
Expdp scott/tiger DIRECTORY=dump DUMPFILE=a.dump CONTENT=METADATA_ONLY

3. DIRECTORY
指定转储文件和日志文件所在的目录
DIRECTORY=directory_object
Directory_object用于指定目录对象名称.需要注意,目录对象是使用CREATE DIRECTORY语句建立的对象,而不是OS目录
Expdp scott/tiger DIRECTORY=dump DUMPFILE=a.dump

4. DUMPFILE
用于指定转储文件的名称,默认名称为expdat.dmp
DUMPFILE=[directory_object:]file_name [,….]
Directory_object用于指定目录对象名,file_name用于指定转储文件名.需要注意,如果不指定directory_object,导出工具会自动使用DIRECTORY选项指定的目录对象
Expdp scott/tiger DIRECTORY=dump1 DUMPFILE=dump2:a.dmp

5. ESTIMATE
指定估算被导出表所占用磁盘空间分方法.默认值是BLOCKS
ESTIMATE={BLOCKS | STATISTICS}
设置为BLOCKS时,oracle会按照目标对象所占用的数据块个数乘以数据块尺寸估算对象占用的空间,设置为STATISTICS时,根据最近统计值估算对象占用空间
Expdp scott/tiger TABLES=emp ESTIMATE=STATISTICS DIRECTORY=dump DUMPFILE=a.dump

6. ESTIMATE_ONLY
指定是否只估算导出作业所占用的磁盘空间,默认值为N
EXTIMATE_ONLY={Y | N}
设置为Y时,导出作用只估算对象所占用的磁盘空间,而不会执行导出作业,为N时,不仅估算对象所占用的磁盘空间,还会执行导出操作.
Expdp scott/tiger ESTIMATE_ONLY=y NOLOGFILE=y

7. EXCLUDE(具体见2、Exclude导出用户中指定类型的指定对象)
该选项用于指定执行操作时释放要排除对象类型或相关对象
EXCLUDE=object_type[:name_clause] [,….]
Object_type用于指定要排除的对象类型,name_clause用于指定要排除的具体对象.EXCLUDE和INCLUDE不能同时使用
Expdp scott/tiger DIRECTORY=dump DUMPFILE=a.dup EXCLUDE=VIEW

8. FILESIZE
指定导出文件的最大尺寸,默认为0,(表示文件尺寸没有限制)

9. FLASHBACK_SCN
指定导出特定SCN时刻的表数据
FLASHBACK_SCN=scn_value
Scn_value用于标识SCN值.FLASHBACK_SCN和FLASHBACK_TIME不能同时使用
Expdp scott/tiger DIRECTORY=dump DUMPFILE=a.dmp FLASHBACK_SCN=358523

10. FLASHBACK_TIME
指定导出特定时间点的表数据
FLASHBACK_TIME=”TO_TIMESTAMP(time_value)”
Expdp scott/tiger DIRECTORY=dump DUMPFILE=a.dmp FLASHBACK_TIME=“TO_TIMESTAMP(’25-08-2004 14:35:00’,’DD-MM-YYYY HH24:MI:SS’)”

11. FULL
指定数据库模式导出,默认为N
FULL={Y | N}
为Y时,标识执行数据库导出.

12. HELP
指定是否显示EXPDP命令行选项的帮助信息,默认为N
当设置为Y时,会显示导出选项的帮助信息.
Expdp help=y

13. INCLUDE(具体见1、Include导出用户中指定类型的指定对象)
指定导出时要包含的对象类型及相关对象
INCLUDE = object_type[:name_clause] [,… ]

14. JOB_NAME
指定要导出作用的名称,默认为SYS_XXX
JOB_NAME=jobname_string
SELECT * FROM DBA_DATAPUMP_JOBS;--查看存在的job

15. LOGFILE
指定导出日志文件文件的名称,默认名称为export.log
LOGFILE=[directory_object:]file_name
Directory_object用于指定目录对象名称,file_name用于指定导出日志文件名.如果不指定directory_object.导出作用会自动使用DIRECTORY的相应选项值.
Expdp scott/tiger DIRECTORY=dump DUMPFILE=a.dmp logfile=a.log

16. NETWORK_LINK
指定数据库链名,如果要将远程数据库对象导出到本地例程的转储文件中,必须设置该选项.
如:expdp gwm/gwm directory=dir_dp NETWORK_LINK=igisdb tables=p_street_area dumpfile =p_street_area.dmp logfile=p_street_area.log     job_name=my_job
igisdb是目的数据库与源数据的链接名,
dir_dp是目的数据库上的目录
而如果直接用使用连接字符串(@fgisdb),expdp属于服务端工具,expdp生成的文件默认是存放在服务端的

17. NOLOGFILE
该选项用于指定禁止生成导出日志文件,默认值为N.

18. PARALLEL
指定执行导出操作的并行进程个数,默认值为1
注:并行度设置不应该超过CPU数的2倍,如果cpu为2个,可将PARALLEL设为2,在导入时速度比PARALLEL为1要快
    而对于导出的文件,如果PARALLEL设为2,导出文件只有一个,导出速度提高不多,因为导出都是到同一个文件,会争抢资源。所以可以设置导出文件为两个,如下所示:
    expdp gwm/gwm directory=d_test dumpfile=gwmfile1.dp,gwmfile2.dp parallel=2

19. PARFILE
指定导出参数文件的名称
PARFILE=[directory_path] file_name

20. QUERY
用于指定过滤导出数据的where条件
QUERY=[schema.] [table_name:] query_clause
Schema用于指定方案名,table_name用于指定表名,query_clause用于指定条件限制子句.QUERY选项不能与CONNECT=METADATA_ONLY,EXTIMATE_ONLY,TRANSPORT_TABLESPACES等选项同时使用.
Expdp scott/tiger directory=dump dumpfile=a.dmp Tables=emp query=’WHERE deptno=20’

21. SCHEMAS
该方案用于指定执行方案模式导出,默认为当前用户方案.

22. STATUS
指定显示导出作用进程的详细状态,默认值为0

23. TABLES
指定表模式导出
TABLES=[schema_name.]table_name[:partition_name][,…]
Schema_name用于指定方案名,table_name用于指定导出的表名,partition_name用于指定要导出的分区名.

24. TABLESPACES
指定要导出表空间列表

25. TRANSPORT_FULL_CHECK
该选项用于指定被搬移表空间和未搬移表空间关联关系的检查方式,默认为N.
当设置为Y时,导出作用会检查表空间直接的完整关联关系,如果表空间所在表空间或其索引所在的表空间只有一个表空间被搬移,将显示错误信息.当设置为N时,导出作用只检查单端依赖,如果搬移索引所在表空间,但未搬移表所在表空间,将显示出错信息,如果搬移表所在表空间,未搬移索引所在表空间,则不会显示错误信息.

26. TRANSPORT_TABLESPACES
指定执行表空间模式导出

27. VERSION
指定被导出对象的数据库版本,默认值为COMPATIBLE.
VERSION={COMPATIBLE | LATEST | version_string}
为COMPATIBLE时,会根据初始化参数COMPATIBLE生成对象元数据;为LATEST时,会根据数据库的实际版本生成对象元数据.version_string用于指定数据库版本字符串.调用EXPDP

数据泵工具导出的步骤:
1、创建DIRECTORY
create directory dir_dp as 'D:\oracle\dir_dp';
2、授权
Grant read,write on directory dir_dp to lttfm;
--查看目录及权限
SELECT privilege, directory_name, DIRECTORY_PATH FROM user_tab_privs t, all_directories d
 WHERE t.table_name(+) = d.directory_name ORDER BY 2, 1;
3、执行导出
expdp lttfm/lttfm@fgisdb schemas=lttfm directory=dir_dp dumpfile =expdp_test1.dmp logfile=expdp_test1.log;

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1
With the Partitioning, OLAP and Data Mining options
启动 "LTTFM"."SYS_EXPORT_SCHEMA_01":  lttfm/********@fgisdb sch
ory=dir_dp dumpfile =expdp_test1.dmp logfile=expdp_test1.log;  */
备注:
   1、directory=dir_dp必须放在前面,如果将其放置最后,会提示 ORA-39002: 操作无效
                                                             ORA-39070: 无法打开日志文件。
                                                             ORA-39087: 目录名 DATA_PUMP_DIR; 无效
    
   2、在导出过程中,DATA DUMP 创建并使用了一个名为SYS_EXPORT_SCHEMA_01的对象,此对象就是DATA DUMP导出过程中所用的JOB名字,如果在执行这个命令时如果没有指定导出的JOB名字那么就会产生一个默认的JOB名字,如果在导出过程中指定JOB名字就为以指定名字出现
     如下改成:
     expdp lttfm/lttfm@fgisdb schemas=lttfm directory=dir_dp dumpfile =expdp_test1.dmp logfile=expdp_test1.log,job_name=my_job1;
   3、导出语句后面不要有分号,否则如上的导出语句中的job表名为‘my_job1;’,而不是my_job1。因此导致expdp lttfm/lttfm attach=lttfm.my_job1执行该命令时一直提示找不到job表
   4、创建的目录一定要在数据库所在的机器上。否则也是提示:

ORA-39002: 操作无效
 ORA-39070: 无法打开日志文件。
ORA-39087: 目录名 DATA_PUMP_DIR; 无效


 

导出的相关命令使用:
   1)Ctrl+C组合键:在执行过程中,可以按Ctrl+C组合键退出当前交互模式,退出之后,导出操作不会停止
   2)Export> status               --查看当前JOB的状态及相关信息
   3)Export> stop_job             --暂停JOB(暂停job后会退出expor模式)
   4)重新进入export模式下:C:\Documents and Settings\Administrator>expdp lttfm/lttfm attach=lttfm.my_job1 --语句后面不带分号
   5)Export> start_job            --打开暂停的JOB(并未开始重新执行)
   6)Export> continue_client      --通过此命令重新启动 "LTTFM"."MY_JOB":
   7)Export> kill_job             --取消当前的JOB并释放相关客户会话(将job删除同时删除dmp文件)
   8)Export> exit_client          --通过此命令退出export模式(通过4)可再进入export模式下)
 注:导出完成后job自动卸载

数据泵导出的各种模式:
1、按表模式导出:
expdp lttfm/lttfm@fgisdb  tables=lttfm.b$i_exch_info,lttfm.b$i_manhole_info dumpfile =expdp_test2.dmp logfile=expdp_test2.log directory=dir_dp job_name=my_job

2、按查询条件导出:
expdp lttfm/lttfm@fgisdb  tables=lttfm.b$i_exch_info dumpfile =expdp_test3.dmp logfile=expdp_test3.log directory=dir_dp job_name=my_job query='"where rownum<11"'

3、按表空间导出:
Expdp lttfm/lttfm@fgisdb dumpfile=expdp_tablespace.dmp tablespaces=GCOMM.DBF logfile=expdp_tablespace.log directory=dir_dp job_name=my_job

4、导出方案
Expdp lttfm/lttfm DIRECTORY=dir_dp DUMPFILE=schema.dmp SCHEMAS=lttfm,gwm

5、导出整个数据库:
expdp lttfm/lttfm@fgisdb dumpfile =full.dmp full=y logfile=full.log directory=dir_dp job_name=my_job


使用exclude,include导出数据
1、Include导出用户中指定类型的指定对象
--仅导出lttfm用户下以B开头的所有表,包含与表相关的索引,备注等。不包含过程等其它对象类型:
expdp lttfm/lttfm@fgisdb dumpfile=include_1.dmp logfile=include_1.log directory=dir_dp job_name=my_job include=TABLE:\"LIKE \'B%\'\"


--导出lttfm用户下排除B$开头的所有表:
expdp lttfm/lttfm@fgisdb schemas=lttfm dumpfile=include_1.dmp logfile=include_1.log directory=dir_dp job_name=my_job include=TABLE:\"NOT LIKE \'B$%\'\"


--仅导出lttfm用户下的所有存储过程:
expdp lttfm/lttfm@fgisdb schemas=lttfm dumpfile=include_1.dmp logfile=include_1.log directory=dir_dp job_name=my_job include=PROCEDURE;  

2、Exclude导出用户中指定类型的指定对象
--导出lttfm用户下除TABLE类型以外的所有对象,如果表不导出那么与表相关的索引,约束等与表有关联的对象类型也不会被导出:
expdp lttfm/lttfm@fgisdb schemas=lttfm dumpfile=exclude_1.dmp logfile=exclude_1.log directory=dir_dp job_name=my_job exclude=TABLE;


--导出lttfm用户下排除B$开头的所有表:
expdp lttfm/lttfm@fgisdb dumpfile=include_1.dmp logfile=include_1.log directory=dir_dp job_name=my_job exclude=TABLE:\"LIKE\'b$%\'\";


--导出lttfm用户下的所有对象,但是对于表类型只导出以b$开头的表:
expdp lttfm/lttfm@fgisdb dumpfile=include_1.dmp logfile=include_1.log directory=dir_dp job_name=my_job exclude=TABLE:\"NOT LIKE \'b$%\'\";


IMPDP介绍

IMPDP命令行选项与EXPDP有很多相同的,不同的有:
1、REMAP_DATAFILE
该选项用于将源数据文件名转变为目标数据文件名,在不同平台之间搬移表空间时可能需要该选项.
REMAP_DATAFIEL=source_datafie:target_datafile

2、REMAP_SCHEMA
该选项用于将源方案的所有对象装载到目标方案中.
REMAP_SCHEMA=source_schema:target_schema

3、REMAP_TABLESPACE
将源表空间的所有对象导入到目标表空间中
REMAP_TABLESPACE=source_tablespace:target:tablespace

4、REUSE_DATAFILES
该选项指定建立表空间时是否覆盖已存在的数据文件.默认为N
REUSE_DATAFIELS={Y | N}

5、SKIP_UNUSABLE_INDEXES
指定导入是是否跳过不可使用的索引,默认为N

6、SQLFILE
指定将导入要指定的索引DDL操作写入到SQL脚本中
SQLFILE=[directory_object:]file_name
Impdp scott/tiger DIRECTORY=dump DUMPFILE=tab.dmp SQLFILE=a.sql

7、STREAMS_CONFIGURATION
指定是否导入流元数据(Stream Matadata),默认值为Y.

8、TABLE_EXISTS_ACTION
该选项用于指定当表已经存在时导入作业要执行的操作,默认为SKIP
TABBLE_EXISTS_ACTION={SKIP | APPEND | TRUNCATE | FRPLACE }
当设置该选项为SKIP时,导入作业会跳过已存在表处理下一个对象;当设置为APPEND时,会追加数据,为TRUNCATE时,导入作业会截断表,然后为其追加新数据;当设置为REPLACE时,导入作业会删除已存在表,重建表病追加数据,注意,TRUNCATE选项不适用与簇表和NETWORK_LINK选项

9、TRANSFORM
该选项用于指定是否修改建立对象的DDL语句
TRANSFORM=transform_name:value[:object_type]
Transform_name用于指定转换名,其中SEGMENT_ATTRIBUTES用于标识段属性(物理属性,存储属性,表空间,日志等信息),STORAGE用于标识段存储属性,VALUE用于指定是否包含段属性或段存储属性,object_type用于指定对象类型.
Impdp scott/tiger directory=dump dumpfile=tab.dmp Transform=segment_attributes:n:table

10、TRANSPORT_DATAFILES
该选项用于指定搬移空间时要被导入到目标数据库的数据文件
TRANSPORT_DATAFILE=datafile_name
Datafile_name用于指定被复制到目标数据库的数据文件
Impdp system/manager DIRECTORY=dump DUMPFILE=tts.dmp
TRANSPORT_DATAFILES=’/user01/data/tbs1.f’调用IMPDP


impdp导入模式:
1、按表导入
p_street_area.dmp文件中的表,此文件是以gwm用户按schemas=gwm导出的:
impdp gwm/gwm@fgisdb  dumpfile =p_street_area.dmp logfile=imp_p_street_area.log directory=dir_dp tables=p_street_area job_name=my_job

2、按用户导入(可以将用户信息直接导入,即如果用户信息不存在的情况下也可以直接导入)
impdp gwm/gwm@fgisdb schemas=gwm dumpfile =expdp_test.dmp logfile=expdp_test.log directory=dir_dp job_name=my_job

3、不通过expdp的步骤生成dmp文件而直接导入的方法:
--从源数据库中向目标数据库导入表p_street_area
impdp gwm/gwm directory=dir_dp NETWORK_LINK=igisdb tables=p_street_area logfile=p_street_area.log  job_name=my_job
igisdb是目的数据库与源数据的链接名,dir_dp是目的数据库上的目录

4、更换表空间
  采用remap_tablespace参数
  --导出gwm用户下的所有数据
expdp system/orcl directory=data_pump_dir dumpfile=gwm.dmp SCHEMAS=gwm
注:如果是用sys用户导出的用户数据,包括用户创建、授权部分,用自身用户导出则不含这些内容
--以下是将gwm用户下的数据全部导入到表空间gcomm(原来为gmapdata表空间下)下
impdp system/orcl directory=data_pump_dir dumpfile=gwm.dmp remap_tablespace=gmapdata:gcomm


exp与imp
exp的关键字说明:
关键字   说明 (默认值)       
------------------------------
USERID   用户名/口令           
BUFFER   数据缓冲区大小        
FILE     输出文件 (EXPDAT.DMP) 
COMPRESS  导入到一个区 (Y)     
GRANTS    导出权限 (Y)         
INDEXES   导出索引 (Y)         
DIRECT    直接路径 (N)  --直接导出速度较快       
LOG      屏幕输出的日志文件     
ROWS      导出数据行 (Y)       
CONSISTENT 交叉表的一致性 (N)  
FULL        导出整个文件 (N)
OWNER      所有者用户名列表
TABLES     表名列表
RECORDLENGTH   IO记录的长度
INCTYPE     增量导出类型
RECORD       跟踪增量导出 (Y)
TRIGGERS     导出触发器 (Y)
STATISTICS    分析对象 (ESTIMATE)
PARFILE      参数文件名
CONSTRAINTS  导出的约束条件 (Y)
OBJECT_CONSISTENT    只在对象导出期间设置为只读的事务处理 (N)
FEEDBACK             每 x 行显示进度 (0)
FILESIZE             每个转储文件的最大大小
FLASHBACK_SCN        用于将会话快照设置回以前状态的 SCN
FLASHBACK_TIME       用于获取最接近指定时间的 SCN 的时间
QUERY                用于导出表的子集的 select 子句
RESUMABLE            遇到与空格相关的错误时挂起 (N)
RESUMABLE_NAME       用于标识可恢复语句的文本字符串
RESUMABLE_TIMEOUT    RESUMABLE 的等待时间
TTS_FULL_CHECK       对 TTS 执行完整或部分相关性检查
TABLESPACES          要导出的表空间列表
TRANSPORT_TABLESPACE 导出可传输的表空间元数据 (N)
TEMPLATE             调用 iAS 模式导出的模板名

 

常用的exp关键字


1、full用于导出整个数据库,在rows=n一起使用,导出整个数据库的结构。
   如:exp userid=gwm/gwm file=/test.dmp log=test.log full=y rows=n direct=y
2、OWNER和TABLES,用于定义exp导出的对象
   如:exp userid=gwm/gwm file=/test.dmp log=test.log owner=gwm table=(table1,table2)
3、buffer和feedback 若导出数据较大,考虑使用这两个参数。
   如:exp userid=gwm/gwm file=/test.dmp log=test.log feedback=10000 buffer=100000000 tables=(table1,table2)
4、file和log 用于指定备份的dmp名称和log名称
5、compress 不压缩导出数据的内容,默认y
6、filesize 若导出的数据文件大,应该用该参数,限制文件大小不要超过2g
   如:exp userid=gwm/gwm file=/test1,test2,test3,test4,test5 filesize=2G log=test.log
       这样将创建test1.dmp,test2.dmp等,每个文件大小为2g。


 

 imp关键字说明
关键字   说明 (默认值)        关键字      说明 (默认值)
-------------------------------------------------------------
USERID   用户名/口令           FULL       导入整个文件 (N)
BUFFER   数据缓冲区大小        FROMUSER    所有者用户名列表
FILE     输入文件 (EXPDAT.DMP)  TOUSER     用户名列表
SHOW     只列出文件内容 (N)     TABLES      表名列表
IGNORE   忽略创建错误 (N)    RECORDLENGTH  IO 记录的长度
GRANTS   导入权限 (Y)          INCTYPE     增量导入类型
INDEXES   导入索引 (Y)         COMMIT       提交数组插入 (N)
ROWS     导入数据行 (Y)        PARFILE      参数文件名
LOG     屏幕输出的日志文件    CONSTRAINTS    导入限制 (Y)

DESTROY                覆盖表空间数据文件 (N)
INDEXFILE              将表/索引信息写入指定的文件
SKIP_UNUSABLE_INDEXES  跳过不可用索引的维护 (N)
FEEDBACK               每 x 行显示进度 (0)
TOID_NOVALIDATE        跳过指定类型 ID 的验证
FILESIZE               每个转储文件的最大大小
STATISTICS             始终导入预计算的统计信息
RESUMABLE              在遇到有关空间的错误时挂起 (N)
RESUMABLE_NAME         用来标识可恢复语句的文本字符串
RESUMABLE_TIMEOUT      RESUMABLE 的等待时间
COMPILE                编译过程, 程序包和函数 (Y)
STREAMS_CONFIGURATION  导入流的一般元数据 (Y)
STREAMS_INSTANTIATION  导入流实例化元数据 (N)

下列关键字仅用于可传输的表空间
TRANSPORT_TABLESPACE 导入可传输的表空间元数据 (N)
TABLESPACES 将要传输到数据库的表空间
DATAFILES 将要传输到数据库的数据文件
TTS_OWNERS 拥有可传输表空间集中数据的用户

 备注:
INCTYPE     增量导入类型 该参数到9i已废弃,我使用的是oracle11g做的实验,发现该参数已无法使用。如下实验所示:
C:\Users\thinkpad>imp fyzh_ora/FYZH_ORA file=rm_trs_seg.dmp log=rm_trs_seg.log f
romuser=ltwebgis inctype=restore

Import: Release 11.1.0.7.0 - Production on 星期二 1月 10 22:18:14 2012
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
经由常规路径由 EXPORT:V10.02.01 创建的导出文件
警告: 这些对象由 LTWEBGIS 导出, 而不是当前用户
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
IMP-00021: INCTYPE 参数已废弃
IMP-00083: 转储文件中不包含增量导出
IMP-00000: 未成功终止导入

 


http://www.linuxidc.com/Linux/2011-03/33392p4.htm
 6.导入单个分区
        [Oracle@node1 ~]$ impdp scott/tiger directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt_imp.log \

        > tables=tb_pt:sal_other skip_unusable_indexes=y table_exists_action=replace

        Import: Release 11.2.0.1.0 - Production on Wed Mar 9 14:13:28 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing options

        Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded

        Starting "SCOTT"."SYS_IMPORT_TABLE_01":  scott/******** directory=dmp dumpfile=tb_pts.dmp logfile=tb_pt_imp.log

            tables=tb_pt:sal_other skip_unusable_indexes=y table_exists_action=replace             --*/

        Processing object type TABLE_EXPORT/TABLE/TABLE

        Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

        . . imported "SCOTT"."TB_PT":"SAL_OTHER"                 71.63 KB    2875 rows

        Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

        Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

        Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

        Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

        Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 14:13:33

 

        SQL> select index_name,status,partitioned from dba_indexes where table_name='TB_PT';

 

        INDEX_NAME                     STATUS   PAR

        ------------------------------ -------- ---

        TB_PT_IND1                     VALID    NO

        TB_PT_LOCAL_IDX                N/A      YES

       

        从上面的导入情况可以看出,尽管执行了truncate partition,然而使用impdp导入工具,并且使用参数table_exists_action=replace

        可以避免使用imp导入时唯一和主键索引需要重建的问题。注意,如果没有使用table_exists_action=replace参数,将会收到ORA-39151

        错误,如下
            ORA-39151: Table "SCOTT"."TB_PT" exists. All dependent metadata and data will be skipped due to

                table_exists_action of skip

 

    7.导入整个表
        [oracle@node1 ~]$ impdp scott/tiger directory=dmp dumpfile=tb_pt.dmp logfile=tb_pt_fullimp.log \

        > tables=tb_pt skip_unusable_indexes=y table_exists_action=replace

        Import: Release 11.2.0.1.0 - Production on Wed Mar 9 14:17:35 2011

        Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

        Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

        With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

        Data Mining and Real Application Testing options

        Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded

        Starting "SCOTT"."SYS_IMPORT_TABLE_01":  scott/******** directory=dmp dumpfile=tb_pt.dmp logfile=tb_pt_fullimp.log

            tables=tb_pt skip_unusable_indexes=y table_exists_action=replace                     --*/

        Processing object type TABLE_EXPORT/TABLE/TABLE

        Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

        . . imported "SCOTT"."TB_PT":"SAL_OTHER"                 71.63 KB    2875 rows

        . . imported "SCOTT"."TB_PT":"SAL_11"                    12.54 KB     298 rows

        . . imported "SCOTT"."TB_PT":"SAL_12"                    14.22 KB     366 rows

        . . imported "SCOTT"."TB_PT":"SAL_13"                    14.18 KB     365 rows

        . . imported "SCOTT"."TB_PT":"SAL_14"                    14.18 KB     365 rows

        . . imported "SCOTT"."TB_PT":"SAL_15"                    14.19 KB     365 rows

        . . imported "SCOTT"."TB_PT":"SAL_16"                    14.23 KB     366 rows

        Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

        Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX

        Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

        Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

        Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 14:17:40

 

五、参数skip_unusable_indexes的作用
    SQL> show parameter skip

 

    NAME                                 TYPE        VALUE

    ------------------------------------ ----------- ------------------------------

    skip_unusable_indexes                boolean     TRUE

 

    该参数允许在导入分区数据时延迟对索引的处理,即先将数据导入,导入后再来重建索引分区。
    在命令行导入中未指定导入参数skip_unusable_indexes时,则对于索引相关的问题,根据数据库初始化参数的值来确定。
    在命令行导入中如果指定了参数skip_unusable_indexes时,则该参数的值优先于数据库初始化参数的设定值。
    skip_unusable_indexes=y对unique index不起作用,因为此时的unique index扮演者constraint的作用,所以在insert数据时index必须被
        更新。
    对于单个分区导入时PK,unique index的处理,必须先重建索引然后进行导入。
    使用impdp数据泵实现导入并使用参数table_exists_action=replace可以解决上述问题,即ORA-01502错误。

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2011-03/33392p4.htmIMPDP


1. 全库导出的parfile
=====================
$ expdp becvx/sun2moon  full=y dumpfile=dp:full%u.dmp  parallel=2  logfile=dp:full.log  job_name=full_export

$ expdp becvx/sun2moon parfile=becvx_full_exp.par

full=y
directory=dp
dumpfile=full%u.dmp
logfile=full.log
parallel=2
job_name=full_export

 

 

2. 泵入多用户的parfile
=====================

$ impdp yzhq/sun2moon  schemas=\(yzhquser1,yzhquser2\) directory=dp  dumpfile=\(full01.dmp,full02.dmp\)  parallel=2  logfile=impdp.log1    job_name=test_import


$ impdp yzhq/sun2moon parfile=yzhq_imp_test.par

schemas=yzhquser1,yzhquser2
directory=dp
dumpfile=full01.dmp,full02.dmp
logfile=impdp.log1
parallel=2
job_name=test_import

 

3. 泵出多用户的parfile
======================

$ expdp  yzhq/sun2moon  schemas=\(YZHQUSER1,YZHQUSER2\)  directory=dp  dumpfile=twouser.dmp  logfile=twouser.log


expdp  yzhq/sun2moon  parfile=two_exp.par

schemas=YZHQUSER1,YZHQUSER2
directory=dp
dumpfile=twouser.dmp
logfile=twouser.log

 


4. 泵入用户表的parfile
=====================

创建用户becvx:

create user becvx identified by sun2moon ;
grant connect, resource to becvx;
create directory dp as '/u02/backup';   <---- 之前执行过后,不用再执行

grant read,write on directory dp to public;

 

$ impdp becvx/sun2moon  tables=\(t1,t2\)  directory=dp  dumpfile=\(full01.dmp,full02.dmp\)    logfile=impdp.log1    job_name=test_import

$ impdp  becvx/sun2moon parfile=imp_becvx_table.par

tables=t1, t2
directory=dp
dumpfile=full01.dmp,full02.dmp
logfile=impdp.log1
job_name=test_import

 


5. 泵出时使用exclude
=====================

正常的命令:
expdp yzhq/sun2moon schemas=becvx exclude=TABLE:"= 'T1'" directory=dp  dumpfile=becvx_export.dmp  logfile=becvx_exp.log  job_name=test_import


在系统上可执行的命令:
$ expdp yzhq/sun2moon schemas=becvx exclude=TABLE:\"= \'T1\'\" directory=dp  dumpfile=becvx_export.dmp  logfile=becvx_exp.log  job_name=test_import

 

expdp yzhq/sun2moon  parfile=yzhq_becvx.par

schemas=becvx
exclude=TABLE:"= 'T1'"
directory=dp
dumpfile=becvx_export.dmp
logfile=becvx_exp.log
job_name=test_import

 

关于排除多个表,可以使用下面的做法:
exclude=TABLE:"= 'T1'",TABLE:"= 'T2'"

或:
exclude=TABLE:"= 'T1'"
exclude=TABLE:"= 'T2'"

这两种方法等价。


[oracle@Manager ~]$ expdp yzhq/sun2moon  parfile=yzhq_becvx.par

Export: Release 10.2.0.4.0 - Production on Wednesday, 10 June, 2009 15:23:54

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

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "YZHQ"."TEST_IMPORT":  yzhq/******** parfile=yzhq_becvx.par
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 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/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "BECVX"."QT"                                4.929 KB       1 rows
. . exported "BECVX"."T2"                                4.960 KB       1 rows
Master table "YZHQ"."TEST_IMPORT" successfully loaded/unloaded
******************************************************************************
Dump file set for YZHQ.TEST_IMPORT is:
  /u02/backup/becvx_export.dmp
Job "YZHQ"."TEST_IMPORT" successfully completed at 15:24:18

[oracle@Manager ~]$

 

======================================================================================================
注意:schema与tables参数不能同时使用, 但它可以include与exclude搭配

expdp yzhq/sun2moon  schemas=becvx tables=\(t1,t2\)  directory=dp dumpfile=becvx01.dmp logfile=exp_becvx.log job_name=exp_becvx


UDE-00010: multiple job modes requested, schema and tables.
======================================================================================================


6. 泵出时使用include
====================

正常的命令:
expdp yzhq/sun2moon schemas=becvx include=TABLE:"IN ('T1','T2')" directory=dp  dumpfile=becvx_export.dmp  logfile=becvx_exp.log  job_name=test_import


在系统上可执行的命令:
expdp yzhq/sun2moon schemas=becvx include=TABLE:\"IN \(\'T1\',\'T2\'\)\" directory=dp  dumpfile=becvx_export.dmp  logfile=becvx_exp.log  job_name=test_import

 

expdp yzhq/sun2moon  parfile=yzhq_becvx.par

schemas=becvx
include=TABLE:"IN ('T1', 'T2')"
directory=dp
dumpfile=becvx_export.dmp
logfile=becvx_exp.log
job_name=test_import

 


[oracle@Manager ~]$ expdp yzhq/sun2moon  parfile=yzhq_becvx.par

Export: Release 10.2.0.4.0 - Production on Wednesday, 10 June, 2009 16:08:53

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

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "YZHQ"."TEST_IMPORT":  yzhq/******** parfile=yzhq_becvx.par
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 192 KB
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . exported "BECVX"."T1"                                67.95 KB     256 rows
. . exported "BECVX"."T2"                                4.960 KB       1 rows
Master table "YZHQ"."TEST_IMPORT" successfully loaded/unloaded
******************************************************************************
Dump file set for YZHQ.TEST_IMPORT is:
  /u02/backup/becvx_export.dmp
Job "YZHQ"."TEST_IMPORT" successfully completed at 16:09:14

[oracle@Manager ~]$

 

7. 泵入时使用exclude
====================

impdp yzhq/sun2moon parfile=imp_becvx.par


schemas=becvx
exclude=TABLE:"= 'T1'"
directory=dp
dumpfile=full01.dmp,full02.dmp
logfile=impdp.log1
parallel=2
job_name=test_import

 

[oracle@testdb11 ~]$ impdp yzhq/sun2moon parfile=imp_becvx.par

Import: Release 10.2.0.4.0 - Production on Wednesday, 10 June, 2009 15:45:40

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

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "YZHQ"."TEST_IMPORT" successfully loaded/unloaded
Starting "YZHQ"."TEST_IMPORT":  yzhq/******** parfile=imp_becvx.par
Processing object type DATABASE_EXPORT/SCHEMA/USER
Processing object type DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/ROLE_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
. . imported "BECVX"."QT"                                4.929 KB       1 rows
. . imported "BECVX"."T2"                                4.960 KB       1 rows
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Job "YZHQ"."TEST_IMPORT" successfully completed at 15:45:46

[oracle@testdb11 ~]$

 

8. NETWORK_LINK(expdp、impdp)
=============================


##########################################################################################################

expdp

NETWORK_LINK

Default: none

Purpose
Enables an export from a (source) database identified by a valid database link. The
data from the source database instance is written to a dump file set on the connected
database instance.

Syntax and Description
NETWORK_LINK=source_database_link

The NETWORK_LINK parameter initiates an export using a database link. This means
that the system to which the expdp client is connected contacts the source database
referenced by the source_database_link, retrieves data from it, and writes the
data to a dump file set back on the connected system.

The source_database_link provided must be the name of a database link to an
available database. If the database on that instance does not already have a database
link, you or your DBA must create one. For more information about the CREATE
DATABASE LINK statement, see Oracle Database SQL Reference.

If the source database is read-only, then the user on the source database must have a
locally managed tablespace assigned as the default temporary tablespace. Otherwise,
the job will fail. For further details about this, see the information about creating
locally managed temporary tablespaces in the Oracle Database Administrator's Guide.


Restrictions

When the NETWORK_LINK parameter is used in conjunction with the TABLES
parameter, only whole tables can be exported (not partitions of tables).
The only types of database links supported by Data Pump Export are: public,
fixed-user, and connected-user. Current-user database links are not supported.

Example

The following is an example of using the NETWORK_LINK parameter. The source_
database_link would be replaced with the name of a valid database link that must
already exist.
> expdp hr/hr DIRECTORY=dpump_dir1 NETWORK_LINK=source_database_link
DUMPFILE=network_export.dmp LOGFILE=network_export.log


##########################################################################################################


impdp


NETWORK_LINK
Default: none

Purpose
Enables a network import when you specify the name of a valid database link to a
source system.

Syntax and Description
NETWORK_LINK=source_database_link


The NETWORK_LINK parameter initiates a network import. This means that the impdp
client initiates the import request, typically to the local database. That server contacts
the remote source database referenced by source_database_link, retrieves the
data, and writes it directly back to the target database. There are no dump files
involved.

The source_database_link provided must be the name of a valid link to a source
database. If the database does not already have a database link, you or your DBA must
create one. For more information about the CREATE DATABASE LINK statement, see
Oracle Database SQL Reference.

If the source database is read-only, then the user on the source database must have a
locally-managed tablespace assigned as a default temporary tablespace. Otherwise,
the job will fail. For further details about this, see the information about creating
locally managed temporary tablespaces in the Oracle Database Administrator's Guide.
This parameter is required when any of the following parameters are specified:
FLASHBACK_SCN, FLASHBACK_TIME, ESTIMATE, or TRANSPORT_TABLESPACES.

Restrictions

Network imports do not support the use of evolved types.
When the NETWORK_LINK parameter is used in conjunction with the TABLES
parameter, only whole tables can be imported (not partitions of tables).
If the USERID that is executing the import job has the IMP_FULL_DATABASE role on
the target database, then that user must also have the EXP_FULL_DATABASE role on
the source database.

The only types of database links supported by Data Pump Import are: public,
fixed-user, and connected-user. Current-user database links are not supported.

Example
In the following example, the source_database_link would be replaced with the
name of a valid database link.
> impdp hr/hr TABLES=employees DIRECTORY=dpump_dir1
NETWORK_LINK=source_database_link EXCLUDE=CONSTRAINT


This example results in an import of the employees table (excluding constraints)
from the source database. The log file is written to dpump_dir1, specified on the
DIRECTORY parameter.

##########################################################################################################


9. network_link泵入泵出测试
==========================


源库:          testdb   becvx
目标库(本地库): ywdb     yzhq


本地库操作:


$ tnsping testdb


SQL> show user;
USER is "YZHQ"
SQL> create database link  bktestdb  connect to becvx identified by sun2moon using 'testdb';

Database link created.

SQL>

 

(1)将源库的用户YZHQUSER1,YZHQUSER2中的数据泵出到本地服务器上
------------------------------------------------------------

权限的分配:

源库:          testdb   becvx      EXP_FULL_DATABASE
目标库(本地库): ywdb     yzhq      EXP_FULL_DATABASE

 

泵出的数据最终会存放到本地库的服务器上,如下所示:

$ expdp yzhq/sun2moon schemas=\(YZHQUSER1,YZHQUSER2\) directory=dp network_link=bktestdb dumpfile=link_exp.dmp  logfile=link_exp.log

Export: Release 10.2.0.4.0 - Production on Wednesday, 10 June, 2009 17:17:10

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

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "YZHQ"."SYS_EXPORT_SCHEMA_01":  yzhq/******** schemas=(YZHQUSER1,YZHQUSER2) directory=dp network_link=bktestdb dumpfile=link_exp.dmp logfile=link_exp.log
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 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/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "YZHQUSER1"."MM1"                           4.929 KB       1 rows
. . exported "YZHQUSER2"."MM2"                           4.921 KB       1 rows
Master table "YZHQ"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for YZHQ.SYS_EXPORT_SCHEMA_01 is:
  /u02/backup/link_exp.dmp
Job "YZHQ"."SYS_EXPORT_SCHEMA_01" successfully completed at 17:17:26

[oracle@testdb11 backup]$


注意:当使用别名连接时(同时也不涉及本地库的权限问题),虽然是在本地操作,但泵出的数据和日志最终还是存放到了源库上。

$ expdp yzhq/sun2moon@testdb schemas=\(YZHQUSER1,YZHQUSER2\) directory=dp dumpfile=link_exp.dmp  logfile=link_exp.log

 

 

(2)将源库的用户YZHQUSER1,YZHQUSER2泵入到目标库中
-------------------------------------------------

权限的分配:

源库:          testdb   becvx      EXP_FULL_DATABASE
目标库(本地库): ywdb     yzhq      IMP_FULL_DATABASE

 

$ impdp yzhq/sun2moon schemas=\(YZHQUSER1,YZHQUSER2\)  network_link=bktestdb logfile=dp:link_imp.log

Import: Release 10.2.0.4.0 - Production on Wednesday, 10 June, 2009 17:34:12

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

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "YZHQ"."SYS_IMPORT_SCHEMA_01":  yzhq/******** schemas=(YZHQUSER1,YZHQUSER2) network_link=bktestdb logfile=dp:link_imp.log
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 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/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . imported "YZHQUSER1"."MM1"                                1 rows
. . imported "YZHQUSER2"."MM2"                                1 rows
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "YZHQ"."SYS_IMPORT_SCHEMA_01" successfully completed at 17:34:27

$

 

10. 本地库利用NETWORK_LINK进行数据泵入
=====================================


示例(1):将本地用户yzhq的数据再备一份为zhq_bak


$ tnsping ywdb


SQL> show user
USER is "YZHQ"
SQL> create database link  linkmyself  connect to yzhq identified by sun2moon using 'ywdb';

 

$ impdp  yzhq/sun2moon  network_link=linkmyself  schemas=yzhq  remap_schema=yzhq:yzhq_bak 

 

注意:
(1)泵入的为本地用户的,要想登入改帐号需要重置密码
(2)由于拷贝的用户既是泵出用户,所以需要将备份的主表删除

SQL> alter user yzhq_bak identified by sun2moon;

User altered.

SQL> conn yzhq_bak
Enter password:
Connected.
SQL> drop table SYS_IMPORT_SCHEMA_01;

Table dropped.

SQL> purge recyclebin;

Recyclebin purged.

SQL>

 

示例(2):将本地用户becvx的数据再备一份为becvx_bak

$ impdp  yzhq/sun2moon  network_link=linkmyself  schemas=becvx  remap_schema=becvx:becvx_bak


同样需要重置密码, 但这时不需要清主表:

SQL> alter user becvx_bak identified by sun2moon;

User altered.

SQL> conn becvx_bak/sun2moon;
Connected.


输入命令:alter system set "_allow_level_without_connect_by" = true;  回车
输入命令:commit; 回车(这个一定不能忘记)
输入命令:exit 回车,退出SQL Plus


说明:现在已经有一部分客户在使用Oracle11g了,在创建数据库前也需要执行以上的操作。


create user ecology identified by ecology default tablespace users Temporary TABLESPACE Temp;

grant connect,resource,exp_full_database,imp_full_database to ecology;

commit;

 

posted on 2013-11-21 11:00  杨锐  阅读(327)  评论(0)    收藏  举报