使用数据泵导入导出数据库
2016-09-05 15:40
393 查看
1.在本地创建转存目录:
oracle@linux:~> mkdir 0905
oracle@linux:~>
2.连接数据库,并创建转存目录:
oracle@linux:~> sqlplus
zxdbp_test/zxdbp_test@zxin;
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Sep 5 15:42:39 2016
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create directory dir_dump as '/home/oracle/0905';
Directory created.
SQL>
使用system用户给转存目录赋予读写权限
SQL> conn system
Enter password:
Connected.
SQL> grant read,write on directory dir_dump to zxdbp_test;
Grant succeeded.
SQL>
2.使用expdp命令对数据库zxdbp_test进行备份:
oracle@linux:~> expdp
zxdbp_test/zxdbp_test@zxin directory=dir_dump dumpfile=1.dmp logfile=1.log;
Export: Release 10.2.0.4.0 - 64bit Production on Monday, 05 September, 2016 15:54:38
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "ZXDBP_TEST"."SYS_EXPORT_SCHEMA_01": zxdbp_test/********@zxin directory=dir_dump dumpfile=1.dmp logfile=1.log
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
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/COMMENT
. . exported "ZXDBP_TEST"."TEST" 11.89 KB 128 rows
Master table "ZXDBP_TEST"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ZXDBP_TEST.SYS_EXPORT_SCHEMA_01 is:
/home/oracle/0905/1.dmp
Job "ZXDBP_TEST"."SYS_EXPORT_SCHEMA_01" successfully completed at 15:55:17
oracle@linux:~>
3.使用impdp导入数据库:
先从数据库中删掉44条记录,
SQL> delete test where rownum<=44;
44 rows deleted.
SQL> commit;
Commit complete.
SQL> select count(*) from test;
COUNT(*)
----------
84
SQL>
然后恢复:
oracle@linux:~> impdp
zxdbp_test/zxdbp_test@zxin directory=dir_dump dumpfile=1.dmp table_exists_action=truncate logfile=2.log;
Import: Release 10.2.0.4.0 - 64bit Production on Monday, 05 September, 2016 16:06:50
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "ZXDBP_TEST"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "ZXDBP_TEST"."SYS_IMPORT_FULL_01": zxdbp_test/********@zxin directory=dir_dump dumpfile=1.dmp
table_exists_action=truncate logfile=2.log
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"ZXDBP_TEST" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
ORA-39153: Table "ZXDBP_TEST"."TEST" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "ZXDBP_TEST"."TEST" 11.89 KB 128 rows
Job "ZXDBP_TEST"."SYS_IMPORT_FULL_01" completed with 2 error(s) at 16:06:53
oracle@linux:~>
恢复完成,其中有一个参数table_exists_action=truncate是指针对存在的表的处理方式,我这里直接truncate掉,然后我们去查一下数据库:
SQL> select count(*) from test;
COUNT(*)
----------
128
SQL>
oracle@linux:~> mkdir 0905
oracle@linux:~>
2.连接数据库,并创建转存目录:
oracle@linux:~> sqlplus
zxdbp_test/zxdbp_test@zxin;
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Sep 5 15:42:39 2016
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create directory dir_dump as '/home/oracle/0905';
Directory created.
SQL>
使用system用户给转存目录赋予读写权限
SQL> conn system
Enter password:
Connected.
SQL> grant read,write on directory dir_dump to zxdbp_test;
Grant succeeded.
SQL>
2.使用expdp命令对数据库zxdbp_test进行备份:
oracle@linux:~> expdp
zxdbp_test/zxdbp_test@zxin directory=dir_dump dumpfile=1.dmp logfile=1.log;
Export: Release 10.2.0.4.0 - 64bit Production on Monday, 05 September, 2016 15:54:38
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "ZXDBP_TEST"."SYS_EXPORT_SCHEMA_01": zxdbp_test/********@zxin directory=dir_dump dumpfile=1.dmp logfile=1.log
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
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/COMMENT
. . exported "ZXDBP_TEST"."TEST" 11.89 KB 128 rows
Master table "ZXDBP_TEST"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ZXDBP_TEST.SYS_EXPORT_SCHEMA_01 is:
/home/oracle/0905/1.dmp
Job "ZXDBP_TEST"."SYS_EXPORT_SCHEMA_01" successfully completed at 15:55:17
oracle@linux:~>
3.使用impdp导入数据库:
先从数据库中删掉44条记录,
SQL> delete test where rownum<=44;
44 rows deleted.
SQL> commit;
Commit complete.
SQL> select count(*) from test;
COUNT(*)
----------
84
SQL>
然后恢复:
oracle@linux:~> impdp
zxdbp_test/zxdbp_test@zxin directory=dir_dump dumpfile=1.dmp table_exists_action=truncate logfile=2.log;
Import: Release 10.2.0.4.0 - 64bit Production on Monday, 05 September, 2016 16:06:50
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "ZXDBP_TEST"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "ZXDBP_TEST"."SYS_IMPORT_FULL_01": zxdbp_test/********@zxin directory=dir_dump dumpfile=1.dmp
table_exists_action=truncate logfile=2.log
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"ZXDBP_TEST" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
ORA-39153: Table "ZXDBP_TEST"."TEST" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "ZXDBP_TEST"."TEST" 11.89 KB 128 rows
Job "ZXDBP_TEST"."SYS_IMPORT_FULL_01" completed with 2 error(s) at 16:06:53
oracle@linux:~>
恢复完成,其中有一个参数table_exists_action=truncate是指针对存在的表的处理方式,我这里直接truncate掉,然后我们去查一下数据库:
SQL> select count(*) from test;
COUNT(*)
----------
128
SQL>
相关文章推荐
- 使用pentaho工具将数据库数据导入导出为Excel
- 使用POI将数据导入导出数据库。
- 使用数据泵expdp命令和impdp命令对数据库的数据进行导入导出
- 使用OPENDATASOURCE和OPENROWSET在不同类型的数据库之间导入导出数据
- 使用plsql将oracle数据库中的数据库结构和数据导出与导入
- Oracle 11g数据库使用pl/sql developer进行数据导入与导出
- ORCLE数据库 使用数据泵方式导入导出数据的误区分析
- 使用sqoop实现关系型数据库、HDFS、Hive之间数据的导入导出
- 使用Sqoop导入导出关系型数据库数据
- 使用数据泵的方式导入导出数据库
- 如何使用mysqldump命令导入导出数据库下的数据或表结构(远程or本地都适合)
- Oracle 使用数据泵 expdp impdp 导入导出数据库“表空间”文件
- SQL 数据的导入导出,对远程(MSsql,OracleAccess,)数据库的操作以及读取Excel,txt文件中的数据
- 使用管道的方式导入导出数据
- 使用DBLink在两个DB间导入/导出数据
- 使用sql语句导入/导出 数据为Excel
- C#中对Excel的操作 使用Excel公式,导入导出数据库等
- Java 使用jxl.jar 导入导出Excel数据
- 使用imp和exp导入导出数据
- Oracle数据导入导出(imp/exp)命令的使用