python实现oracle数据泵导出功能

脚本如下:
[oracle@ycr python]$ more dump.py 
#/usr/bin/python
#coding:utf8

import sys
import os
import time

nowt=time.strftime('%Y%m%d%H',time.localtime())
excmd='expdp %s/%s@%s directory=YCRDUMP dumpfile=ycrdump%s.dmp' % (sys.argv[1],sys.argv[2],sys.argv[3],nowt)
result=os.system(excmd)

测试结果如下:

[oracle@ycr python]$ python dump.py test oracle ycr2              ---------三个参数分别为,用户名test,密码oracle和连接字符串ycr2

Export: Release 12.1.0.2.0 - Production on Wed Aug 3 02:52:00 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Starting "TEST"."SYS_EXPORT_SCHEMA_01":  test/********@ycr2 directory=YCRDUMP dumpfile=ycrdump2016080302.dmp 
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/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
. . exported "TEST"."T2"                                 16.78 KB       4 rows
. . exported "TEST"."T3"                                 12.21 KB       3 rows
. . exported "TEST"."T1"                                     0 KB       0 rows
Master table "TEST"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for TEST.SYS_EXPORT_SCHEMA_01 is:
  /u01/app/oracle/ycrdump2016080302.dmp
Job "TEST"."SYS_EXPORT_SCHEMA_01" successfully completed at Wed Aug 3 02:52:46 2016 elapsed 0 00:00:44

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29135257/viewspace-2122885/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29135257/viewspace-2122885/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值