background image

oracle 导出导入操作

基础知识:

一、数据导出(

exp.exe)

1、将数据库 orcl 完全导出,用户名 system,密码 accp,导出到 d:\daochu.dmp 文件中
exp system/accp@orcl file=d:\daochu.dmp full=y
2、将数据库 orcl 中 scott 用户的对象导出
exp scott/accp@orcl file=d:\daochu.dmp  owner=(scott)
3、将数据库 orcl 中的 scott 用户的表 emp、dept 导出
exp scott/accp@orcl file= d:\daochu.dmp tables=(emp,dept)
4、将数据库 orcl 中的表空间 testSpace 导出
exp system/accp@orcl file=d:\daochu.dmp tablespaces=(testSpace)
二、数据导入(

imp.exe)

1、将 d:\daochu.dmp 

 

中的数据导入

orcl 数据库中。

imp system/accp@orcl file=d:\daochu.dmp full=y
2、如果导入时,数据表已经存在,将报错,对该表不会进行导入;加上 ignore=y 即可,表
示忽略现有表,在现有表上追加记录。
imp scott/accp@orcl file=d:\daochu.dmp  full=y  ignore=y
3、将 d:\daochu.dmp 中的表 emp 导入
imp scott/accp@orcl file=d:\daochu.dmp tables=(emp)
ok,现在尝试导出数据
首先查看字符集
select userenv(‘language’) from dual;
分别查看字符集是否相同,不相同的话更改一致,否则不能正常导入
我在执行过程中出现错误

 error: ora-12712(解决办法)

shutdown immediate;
startup mount;
ALTER SESSION SET SQL_TRACE=TRUE;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
set linesize 120;
alter database character set zhs16gbk;
RROR at line 1:
  

ORA-12712: new character set must be a superset of old character set

ALTER DATABASE character set INTERNAL_USE zhs16gbk;
ALTER SESSION SET SQL_TRACE=FALSE;
shutdown immediate;
STARTUP
执行导出命令
exp scott/cat@orcl wner=scott direct=y file=scott.dmp