脚本如下:
[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
[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/