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.