Oracle11G 数据库 expdp、impdp使用示例
2015-07-18 18:49
453 查看
expdp 备份数据库、expdp/impdp简单测试
操作系统层面创建目录
[root@Oracle11g ~]# mkdir -p /home/oracle/db_back/
修改目录的所属用户、所属组
[root@Oracle11g ~]# chown -R oracle:oinstall /home/oracle/db_back/
给目录授予相应的权限
(用户对 该目录应该有 读+写+执行 的权限)
[root@Oracle11g ~]# chmod 700 /home/oracle/db_back/
oracle数据库层面创建目录
SQL> create directory ora_back as '/home/oracle/db_back/';
Directory created.
授予相应用户的执行权限
SQL> grant all on directory ora_back to system;
Grant succeeded.
授予用户 全库导出的权限
SQL> grant EXPORT FULL DATABASE to system;
Grant succeeded.
查看执行 全库导出的脚本
[oracle@Oracle11g scripts]$ cat expdp.sh
以下附带 错误操作及 错误分析
错误操作1
[root@Oracle11g ~]# chmod 600 /home/oracle/db_back/
[oracle@Oracle11g scripts]$ sh expdp.sh
Export: Release 10.2.0.1.0 - 64bit Production on Tuesday, 02 December, 2014 16:05:46
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 475
ORA-29283: invalid file operatio
错误分析:
oracle用户对该目录只有 读+写 的权限
----------------------------------------------------------------------------------------------------------------------------
导入导出测试:
测试用意: scott用户删除表EMP,然后执行导入操作 检查表是否 重建 。重建后的 表是否在 移动后的表空间
SQL> conn scott/tiger
Connected.
SQL> drop table emp purge;
Table dropped.
[oracle@Oracle11g scripts]$ vi expdp.sh 内容如下:
expdp system/oracle directory=ora_bak file=071501.dmp file=071502.dmp dumpfile=071501.dmp file=071502.dmp log=0715_full.log full=y filesize=300m
此处指定导出文件的最大size 300M,只是为了还原朋友反馈的问题
[oracle@Oracle11g scripts]$ vi impdp.sh 内容如下:
impdp system/oracle directory=ora_bak dumpfile=071501.dmp dumpfile=071502.dmp remap_tablespace=users:test01 logfile=0715_impdp.log table_exists_action=truncate
检查表EMP 是否重建,重建后的表空间是否是 TEST01
SQL> select owner,table_name,tablespace_name from all_tables where owner='SCOTT';
OWNER TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
SCOTT DEPT USERS
SCOTT SALGRADE USERS
SCOTT YOUYUS USERS
SCOTT SALES USERS
SCOTT T USERS
SCOTT MLOG$_T USERS
SCOTT EMP TEST01
SCOTT T_NEW
SCOTT RUPD$_T
SCOTT SALES01
SCOTT BONUS USERS
SCOTT TEST TEST01
结果跟自己预想的一样!!
哈哈
操作系统层面创建目录
[root@Oracle11g ~]# mkdir -p /home/oracle/db_back/
修改目录的所属用户、所属组
[root@Oracle11g ~]# chown -R oracle:oinstall /home/oracle/db_back/
给目录授予相应的权限
(用户对 该目录应该有 读+写+执行 的权限)
[root@Oracle11g ~]# chmod 700 /home/oracle/db_back/
oracle数据库层面创建目录
SQL> create directory ora_back as '/home/oracle/db_back/';
Directory created.
授予相应用户的执行权限
SQL> grant all on directory ora_back to system;
Grant succeeded.
授予用户 全库导出的权限
SQL> grant EXPORT FULL DATABASE to system;
Grant succeeded.
查看执行 全库导出的脚本
[oracle@Oracle11g scripts]$ cat expdp.sh
#!/bin/bash export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 export ORACLE_SID=orcl expdp system/manager directory=ora_back dumpfile=$ORACLE_SID+`date +%Y+%m+%d+%H+%M+%S`.dmp full=y logfile=$ORACLE_SID+`date +%Y+%m+%d+%H+%M+%S`.log |
错误操作1
[root@Oracle11g ~]# chmod 600 /home/oracle/db_back/
[oracle@Oracle11g scripts]$ sh expdp.sh
Export: Release 10.2.0.1.0 - 64bit Production on Tuesday, 02 December, 2014 16:05:46
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 475
ORA-29283: invalid file operatio
错误分析:
oracle用户对该目录只有 读+写 的权限
----------------------------------------------------------------------------------------------------------------------------
导入导出测试:
测试用意: scott用户删除表EMP,然后执行导入操作 检查表是否 重建 。重建后的 表是否在 移动后的表空间
SQL> conn scott/tiger
Connected.
SQL> drop table emp purge;
Table dropped.
[oracle@Oracle11g scripts]$ vi expdp.sh 内容如下:
expdp system/oracle directory=ora_bak file=071501.dmp file=071502.dmp dumpfile=071501.dmp file=071502.dmp log=0715_full.log full=y filesize=300m
此处指定导出文件的最大size 300M,只是为了还原朋友反馈的问题
[oracle@Oracle11g scripts]$ vi impdp.sh 内容如下:
impdp system/oracle directory=ora_bak dumpfile=071501.dmp dumpfile=071502.dmp remap_tablespace=users:test01 logfile=0715_impdp.log table_exists_action=truncate
检查表EMP 是否重建,重建后的表空间是否是 TEST01
SQL> select owner,table_name,tablespace_name from all_tables where owner='SCOTT';
OWNER TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
SCOTT DEPT USERS
SCOTT SALGRADE USERS
SCOTT YOUYUS USERS
SCOTT SALES USERS
SCOTT T USERS
SCOTT MLOG$_T USERS
SCOTT EMP TEST01
SCOTT T_NEW
SCOTT RUPD$_T
SCOTT SALES01
SCOTT BONUS USERS
SCOTT TEST TEST01
结果跟自己预想的一样!!
哈哈
相关文章推荐
- oracle数据库(一)之oracle 11g安装篇
- Oracle,SQL多重排序--多字段排序
- SQL语句oracle中如何插入Date类型的数据
- oracle账号解锁
- Mybatis映射Oracle Spatial和Jgeometry
- ORACLE认证
- ORACLE分页查询
- oracle官方文档
- oracle官方文档
- Oracle imp exp expdp impdp
- Oracle手动创建数据库
- [Oracle] - 性能优化工具(3) - ADDM
- plsql连接win7 64位系统的oracle
- oracle10g卸载方法
- oracle 删除掉重复数据只保留一条 .
- 【Oracle 集群】ORACLE DATABASE 11G RAC 知识图文详细教程之RAC 特殊问题和实战经验(五)
- oracle10g监听器无法启动,提示“错误1067:进程意外终止”
- oracle 11g rac 在linux 6.3上安装的注意事项
- 开发PL/SQL子程序和包及使用PL/SQL编写触发器、在JDBC中应用Oracle
- PLSQL连接远程ORACLE数据库中文乱码解决