Oracle数据的导入与导出

一、EXPDP与IMPDP 

EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用。


EXPDP和IMPDP是服务端的工具程序,他们只能在ORACLE服务端使用,不能在客户端使用。


IMP只适用于EXP导出的文件,不适用于EXPDP导出文件;IMPDP只适用于EXPDP导出的文件,而不适用于EXP导出文件。


expdp或impdp命令时,可暂不指出用户名/密码@实例名 as 身份,然后根据提示再输入,

expdp schemas=scott dumpfile=expdp.dmp DIRECTORY=mys

--1)电脑上创建一个导出的存放目录  c:\hlx

--必须在system用户下创建
--2)数据库中创建导出导入的文件夹,并制定文件位置
create directory mys as 'c:\hlx'

--3)授权用户操作导入导出文件夹
grant read,write on directory mys to scott;

--4)用scott用户登录
--(1)导出数据库语法:
--expdp  用户名/密码   directory=导出导入文件夹 dumpfile= 导出文件名.dmp  
--logfile=导出日志.log  SCHEMAS=用户名 version =版本号


--(a)完整的数据库
  expdp system/hlxoracle@HLX directory=mys dumpfile=all.dmp full=y
  
--(b)用户
  expdp scott/hsx@HLX directory=mys dumpfile=scott.dmp  schemas=scott
  
--(c)表
 expdp scott/hsx@HLX directory=mys dumpfile=tables.dmp  tables=emp,dept,student


--(d)表空间
  --system用户下查看表空间  (必须用当前这个用户,必须有操作导入导出文件夹) MYS1_TABLESPACE 
  -- expdp zz/aaa@HLX  directory=mys  dumpfile=tablespace.dmp  tablespaces=MYS1_TABLESPACE
  
  expdp scott/hsx@HLX  directory=mys  dumpfile=tablespace.dmp  tablespaces=USERS




/*导入脚本*/
/*impdp 用户名/密码   directory=导出导入文件夹  dumpfile= 导入文件名.dmp  
logfile=导入日志.log   REMAP_SCHEMA=导出用户名 :导入用户名
REMAP_TABLESPACE=导出表空间:导入表空间 version=版本号*/
--(a)完整的数据库
   impdp system/hlxoracle@HLX directory=mys dumpfile=all.dmp full=y
   
--(b)将scott用户将数据导入到QQ用户
  impdp system/hlxoracle@HLX directory=mys dumpfile=scott.dmp  remap_schema=scott:qq


--(c)表
  --user  zhang /my
   create user zhang identified by aaa;
   grant connect,resource to zhang;
   
    grant connect,resource to my;
   impdp system/hlxoracle@HLX directory=mys dumpfile=tables.dmp  tables=emp,dept  remap_schema=scott:zhang


--(d)表空间
   impdp scott/hsx@HLX  directory=mys  dumpfile=tablespace.dmp  tablespaces=USERS
   


二、EXP与IMP 


 有三种主要的方式(完全、用户、表)  
 1、完全: 
    exp system/hlxoracle@HLX  file='C:\hlx\my\all.dmp' full=y 
 
 2、用户:
    exp zhang/aaa@HLX  file='C:\hlx\my\zhang.dmp' owner=zhang 
 
 3、表
    exp scott/hsx@HLX  file='C:\hlx\my\emp.dmp'  tables=(emp)
    
 -----IMP----->   
 1、完全: 
    imp system/hlxoracle@HLX  file='C:\hlx\my\all.dmp' full=y 
 
 2、用户: 
    imp system/hlxoracle@HLX  file='C:\hlx\my\zhang.dmp' fromuser=zhang touser=my 
 
 3、表
    imp zhang/aaa@HLX  file='C:\hlx\my\emp.dmp' tables=(emp)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值