五、数据泵的监控
1.查询dba_directories获得所创建的目录
2.可以查询dba_datapump_jobs来查看数据泵作业的运行情况,也可以利用ATTACH重新连接上还在进行的JOB
每个datapump可以通过job_name 参数来指定作业名称,如未指定,则系统使用默认的作业名称,如下面的视图中为SYS_EXPORT_FULL_01
通过v$session_longops也可以查看长时间运行的datapump job的具体内容
SQL> select owner_name owr,job_name jbn,operation ope,job_mode jbm,state,degree,
2 attached_sessions atts,datapump_sessions dats
3 from dba_datapump_jobs;
OWR JBN OPE JBM STATE DEGREE ATTS DATS
---------- -------------------- -------------------- --------------- ---------- ---------- ---------- ----------
SCOTT SYS_EXPORT_FULL_01 EXPORT FULL COMPLETING 2 1 2
SQL> select sid, serial#,session_type
2 from v$session s, dba_datapump_sessions d
3 where s.saddr = d.saddr;
SID SERIAL# SESSION_TYPE
---------- ---------- --------------
143 10 DBMS_DATAPUMP
149 37 MASTER
132 3 WORKER
136 3 WORKER
135 4 WORKER
141 5 WORKER
128 2 WORKER
142 4 WORKER
3.监控数据泵的逻辑备份程度
SELECT sid, serial#, context, sofar, totalwork,
ROUND(sofar/totalwork*100,2) "%_COMPLETE"
FROM v$session_longops
WHERE opname LIKE '%EXP%'
AND totalwork != 0
AND sofar <> totalwork;
SID SERIAL# CONTEXT SOFAR TOTALWORK %_COMPLETE
130 33 0 54 70 77.14
六、expdp的常用参数
1.content: 该选项用于指定要导出的内容.默认值为ALL
CONTENT={ALL | DATA_ONLY | METADATA_ONLY}
expdp scott/tiger schemas=scott content=all
expdp scott/tiger tables=emp content=data_only directory=dump_scott dumpfile=empdata.dmp(只导出对象数据)
expdp scott/tiger tables=emp content=metadata_only directory=dump_scott dumpfile=empmd.dmp(只有定义信息)
2.estimate: 指定估算被导出表所占用磁盘空间分方法.默认值是blocks
expdp scott/tiger directory=dump_scott dumpfile=dba_object.dmp tablespaces=users estimate=statistics
expdp scott/tiger directory=dump_scott dumpfile=dba_object.dmp tablespaces=users estimate=blocks
3.extimate_only:指定是否只估算导出作业所占用的磁盘空间,默认值为N
expdp scott/tiger schemas=scott estimate_only=y
设置为Y时,导出作用只估算对象所占用的磁盘空间,而不会执行导出作业,
为N时,不仅估算对象所占用的磁盘空间,还会执行导出操作.
4.exclude:该选项用于指定执行操作时释放要排除对象类型或相关对象
exclude=view
exclude=package
exclude=index:"like 'EMP%'
object_type用于指定要排除的对象类型,name_expr用于指定要排除的具体对象.exclude和include不能同时使用
expdp scott/tiger schemas=scott exclude=view dumpfile=a9.dmp
include = object_type[:"name_expr"]
5.filesize:指定导出文件的最大尺寸,默认为,(表示文件尺寸没有限制)
6.flashback_scn: 前提闪回功能开启
expdp scott/tiger tables=emp dumpfile=e2.dmp flashback_scn=4284715
如果闪回的时间点该对象结构发生变化,将报错(比如该对象没有创建或者ddl操作)
7.flashback_time:指定导出特定时间点的表数据
expdp scott/tiger DIRECTORY=dump DUMPFILE=a.dmp FLASHBACK_TIME="TO_TIMESTAMP(’-08-2004 14:35:00’,’DD-MM-YYYY HH24:MI:SS’)"
windows下:
C:/>expdp scott/tiger DIRECTORY=dump_dir DUMPFILE=a.dmp
flashback_time=/"TO_TIMESTAMP('06-04-2010 11:24:26', 'DD-MM-YYYY HH24:MI:SS')/"
8.query导出查询得到的结果集
query=scott.emp :"where deptno = 30 and sal > 3500"
9.sample 使用该参数进行对导出的数据进行采样
sample="scott"."emp":20
expdp scott/tiger directory=dump_scott dumpfile=sam.dmp sample=30
10.dumpfile 指定导出时的文件名
dumpfile=scott_tb.dmp
dumpfile=scott_tb_%u.dmp %u 用于扩展导出的文件名,固定长度为个字符,从开始递增,使用并行导出时建议指定该参数
