情况1
emp_main表需要根据sendtime字段导出2018年的数据
参数文件emp_main.par的内容如下:
tables=emp_main
dumpfile=emp_main.dmp
logfile=emp_main.log
query="where sendtime between to_date('20180101','yyyymmdd') and to_date('20190101','yyyymmdd')"
执行导出的命令如下:
expdp 用户名/密码@服务名 directory=exp_dir parfile=emp_main.par
情况2
在导出2018年的emp_main表后,需要导出emp_detail中与之关联的数据,且exp_detail表没有日期字段,但与exp_main通过某字段相关联
参数文件emp_detail.par的内容如下
tables=emp_detail
dumpfile=emp_detail.dmp
logfile=emp_detail.log
query=(emp_detail:"where exists(select 1 from emp_main a where sheetkey = a.id and a.sendtime between to_date('20180101','yyyymmdd') and to_date('20190101','yyyymmdd'))")
执行导出的命令如下:
expdp 用户名/密码@服务名 directory=exp_dir parfile=emp_detail.par
其他说明
上述是用expdp命令。如果是exp,则需要将参数文件中的参数名改为如下:
tables=emp_main
file=emp_main.dmp
log=emp_main.log
query="where sendtime between to_date('20180101','yyyymmdd') and to_date('20190101','yyyymmdd')"
导出命令为:
exp 数据库用户名/密码@连接名 parfile=emp_main.par