Oracle Data Pump 导出和导入数据(5)

  整库导出必须使用sysdba权限;

expdp userid='sys/oracle as sysdba' job_name=export_schema FULL=Y directory=pump_dir dumpfile=full_dbexport.dmp logfile=full_dbexport.log 1.5查询导数job状态 column username format a10 column opname format a20 column units format a10 select round(sofar/totalwork*100,2) percent_completed, t.sid,t.SERIAL#,t.USERNAME,t.OPNAME,t.TOTALWORK,t.UNITS,t.START_TIME,t.MESSAGE from v$session_longops t where sofar <> totalwork order by target,sid; PERCENT_COMPLETED SID SERIAL# USERNAME OPNAME TOTALWORK UNITS START_TIME MESSAGE ----------------- ---------- ---------- ---------- -------------------- ---------- ---------- -------------- --------------------------------------------------------------------------- 70.88 128 17213 FRDC Table Scan 2533381 Blocks 02-6月 -15 Table Scan: FRDC.H_BASE_MAIN05_T: 1795601 out of 2533381 Blocks done 12.58 128 17213 FRDC Table Scan 2533381 Blocks 02-6月 -15 Table Scan: FRDC.H_BASE_MAIN05_T: 318705 out of 2533381 Blocks done 70.74 128 17213 FRDC Table Scan 2533381 Blocks 02-6月 -15 Table Scan: FRDC.H_BASE_MAIN05_T: 1792046 out of 2533381 Blocks done 29.06 4 57701 FRDC Index Fast Full Scan 2127 Blocks 13-5月 -15 Index Fast Full Scan: FRDC.O_BASE_DW: 618 out of 2127 Blocks done 0 5 280 SYS Rowid Range Scan 4294967296 Blocks 02-6月 -15 Rowid Range Scan: FRDC.O_BASE_DW_T: 22055 out of 0 Blocks done 0 427 54951 FRDC EXPORT_TB 7900 MB 02-6月 -15 EXPORT_TB: EXPORT : 0 out of 7900 MB done

回到顶部

2数据导入 2.1基本语法 $ impdp userid='uname/pwd' directory=pump_dir dumpfile=file01.dmp job_name='' log_file='' remap_schema='scott:sywu' remap_table='tb01:tb02' remap_tablespace='tbs01:ts01' tables='' schemas='' table_exists_action='' tablespaces='' exclude='' sqlfile=''

上面有的参数这里就不重复了,因为dump方式导出数据使用了xml格式,所以导入时很容易实现对象重新定义操作,这里主要说几个经常使用的参数:
remap_schema 表示重新定义schema,将旧的schema定义为新的schema,格式old:new,old:new....;
remap_table 表示重新定义表名,格式oldtbname:newtbname,....;
remap_tablespace 表示重新定义表空间名,格式old:new....;
tables 表示要导入的表名,如果未指定则导入dumpfile里的所有表;
schemas 表示要导入的schema对象,如果未指定并且操作用户有权限则导入dumpfile里的所有schema;
table_exists_action 表示当导入表时如果表已经存在时的操作,参数值可以为:append(追加)、replace(替换数据库中存在的)、truncate(删除已经存在的数据,导入dumpfile里面的数据)、skip(不做任何操作);
tablespaces 表示导入的表空间名;
exclude 表示导入排除的对象,DATABASE_EXPORT_OBJECTS表中记录所有的(数据库级别)排除模式,SCHEMA_EXPORT_OBJECTS表中记录schema级别排除对象模式,TABLE_EXPORT_OBJECTS表中记录table级别排除对象模式;
sqlfile 表示不导入数据仅生成导数ddl语句记录在该文件中;

2.2导入数据

导入数据时要确认导入的用户是否存在,是否有权限访问表空间、是否具有读写directory的权限;

$ impdp userid='ops$sywu/sywu' schemas='ops$sywu' directory=pump_dir job_name=import_opssywu dumpfile=export_opssywu.dmp Import: Release 11.2.0.3.0 - Production on Sat Jun 6 13:39:43 2015 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "OPS$SYWU"."IMPORT_OPSSYWU" successfully loaded/unloaded Starting "OPS$SYWU"."IMPORT_OPSSYWU": userid=ops$sywu/******** schemas=ops$sywu directory=pump_dir job_name=import_opssywu dumpfile=export_opssywu.dmp Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Processing object type SCHEMA_EXPORT/TABLE/TABLE Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA . . imported "OPS$SYWU"."TB01" 74.64 MB 844416 rows . . imported "OPS$SYWU"."TB02" 452.3 KB 13448 rows . . imported "OPS$SYWU"."T_EXCE" 5.820 KB 2 rows Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS Job "OPS$SYWU"."IMPORT_OPSSYWU" successfully completed at 13:39:55

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/43bf65e73c0c33098e3a92024cfde3a3.html