分类: Oracle
Oracle exp导出加where指定条件
exp username/password@192.168.x.x/orcl file = F:\nc\bd_corp.dmp tables="(bd_corp)" query = \"where PK_CORP IN(1015,1156) AND TS < '2017-12-31 23:59:59' AND TS > '2015-01-01 00:00:00' \"

另导入数据时加上 ignore=y 会忽略掉错误信息

exp system/123456 file=test.dmp tables=table1,table2,table3 log=test.log

或者

exp system/123456 file=test.dmp tables="(table1,table2,table3)" log=test.log

多个tables要加上双引号,
将数据库完全导出,设置full选项

exp system/manager@orcl file=d:\db.dmp full=y

导出数据库结构,不导出数据,设置rows选项

exp system/manager@orcl file=d:\db.dmp rows=n full=y

当导出数据量较大时,可以分成多个文件导出,设置filesize选项

exp system/manager@orcl file=d:\db1.dmp,d:\db2.dmp filesize=50M full=y

将数据库中system用户与sys用户的表导出,设置owner选项

exp system/manager@orcl file=d:\Test_bak.dmp owner=(system,sys)

将数据库中的表t_result,t_khtime导出,设置tables选项

exp system/manager@orcl file= d:\Test_bak.dmp tables=(t_result,t_khtime)

将数据库中的表T_SCORE_RESULT中updatedate日期字段大于某个值的数据导出,设置query选项

exp kpuser/kpuser@orcl file=d:\Test_bak.dmp tables=(T_SCORE_RESULT) query=\" where updatedate>to_date('2016-9-1 18:32:00','yyyy-mm-dd hh24:mi:ss')\"

如果使用了tables就不能用owner,如果用了owner就不能用tables否则回报错;
当需要导入/导出的数据量比较大时,这个过程需要的时间是比较长的,我们可以用一些方法来优化exp的操作。

1)使用直接路径 direct=y,oracle会避开sql语句处理引擎,直接从数据库文件中读取数据,然后写入导出文件
2)如果没有使用直接路径,必须保证buffer参数的值足够大.


相关博文:

发表新评论