【Oracle】Oracle-Linux下数据导出脚本实现(四)

Linux下数据导出脚本

创建两个脚本文件,同时给予可执行的权限
[oracle@demoserver oraclesrcipts]$ ll
total 8
-rwxr--r-x 1 oracle oinstall 177 Aug 19 08:41 expdpData.properties
-rwxr--r-x 1 oracle oinstall 102 Aug 19 08:40 expdpData.sh
expdpData.sh文件内容
[oracle@demoserver oraclesrcipts]$ more expdpData.sh
#!/bin/sh
echo 'starting expdp data.....'
exp parfile=expdpData.properties
echo 'finish expdp data'
expdpData.properties文件内容
[oracle@demoserver oraclesrcipts]$ more expdpData.properties
userid=ngves3/asiainfo@192.168.204.135:1521/mydb
compress=y
file=/tmp/backup/expdata_20130820_1.dmp
direct=y
indexes=y
log=/tmp/backup/expdata_20130820.log
tables=t_user,t_dept
执行shell脚本
[oracle@demoserver oraclesrcipts]$ sh expdpData.sh
starting expdp data.....
Export: Release 10.2.0.1.0 - Production on Mon Aug 19 08:45:33 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
About to export specified tables via Direct Path ...
. . exporting table T_USER 5 rows exported
. . exporting table T_DEPT 0 rows exported

Export terminated successfully without warnings.
finish expdp data

 

Linux下数据导入脚本

impdpData.sh文件内容
[oracle@demoserver oraclesrcipts]$ more impdpData.sh
#!/bash/sh
echo 'starting impdp data.....'
imp userid=ngves3/asiainfo@mydb file=/tmp/backup/expdata_20130820_1.dmp fromuser=ngves3 touser=check_ngves3 IGNORE=Y log=/tmp/backup
/impdata_20130820_1.log
echo 'finish impdp data'
执行shell脚本
[oracle@demoserver oraclesrcipts]$ sh impdpData.sh
starting impdp data.....
Import: Release 10.2.0.1.0 - Production on Mon Aug 19 08:53:12 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via direct path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing NGVES3's objects into CHECK_NGVES3
. . importing table "T_USER" 5 rows imported
. . importing table "T_DEPT" 0 rows imported
Import terminated successfully without warnings.
finish impdp data

 

Linux下数据导入表结构和数据

 

第一步:创建import_table.sh脚本
[oracle@demoserver oraclesrcipts]$ more import_table.sh
#!/bin/sh
imp
userid=ngves3/asiainfo@mydb fromuser=ngves3 touser=check_ngves3 file=/tmp/backup/expdata_20130820_1.dmp CONSTRAINTS=n rows=n
GRANTS=n IGNORE=n log=/tmp/backup/impdata_20130820_2.log
第二步:执行import_table.sh脚本
[oracle@demoserver oraclesrcipts]$ sh import_table.sh
Import: Release 10.2.0.1.0 - Production on Mon Aug 19 09:04:59 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via direct path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing NGVES3's objects into CHECK_NGVES3
Linux 5 下 Oracle10 使用手册 1.0 版
- 14 -
Import terminated successfully without warnings.
第三步:导入表数据脚本import_data.sh
[oracle@demoserver oraclesrcipts]$ more import_data.sh
#!/bin/sh
imp userid=ngves3/asiainfo@mydb file=/tmp/backup/expdata_20130820_1.dmp fromuser=ngves3 touser=check_ngves3 GRANTS=n IGNORE=y log=/t
mp/backup/impdata_20130820_3.log
第四步:执行入表数据的脚本import_data.sh
[oracle@demoserver oraclesrcipts]$ sh import_data.sh
Import: Release 10.2.0.1.0 - Production on Mon Aug 19 09:10:21 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via direct path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing NGVES3's objects into CHECK_NGVES3
. . importing table "T_USER" 5 rows imported
. . importing table "T_DEPT" 0 rows imported
Import terminated successfully without warnings.

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

艾文教编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值