oracle exp和imp的用法

exp是导出的意思,imp是导入的意思。

以下都是我使用xshell连接redhat5.5中oracle11g R2测试结果

首先需要切换到oracle账号,su – oracle

exp system/oracle@orcl file=/home/oracle/backup/full.dmp full=y

全部导出,使用system账号,后面oracle为密码,orcl是实例名称,full是全备的意思

exp system/oracle@orcl file=/home/oracle/bakup/scotthr.dmp owner=scott,hr

导出owner为scott和hr的duixiang

exp scott/tiger@orcl file=/home/oracle/backup/deptemp.dmp tables=dept,emp

导出scott的dept和emp两张表

使用sys账号导出时,需要使用转义字符,因为sys 必需要加as sysdba

exp ”sys/oracle@orcl as sysdba” file=/home/oracle/backup/testsys.dmp owner=dept,emp

把scott.dept和scott.emp导入

imp scott/tiger@orcl file=/home/oracle/backup/deptemp.dmp

这样会失败,following statement failed because the object already exists:

image

imp scott/tiger@orcl file=/home/oracle/backup/deptemp.dmp ignore=y

忽略还是会有警告

image

直接把scott.dept和scott.emp删除,再重新还原应该就没有问题了,试试吧:

drop table scott.emp;

drop table scott.dept;

imp scott/tiger@orcl file=/home/oracle/backup/deptemp.dmp

image

原文地址:https://www.cnblogs.com/cnmarkao/p/3672121.html