Oracle导入导出详解

Oracle导入导出采用数据泵的方式

导出:

expdp user/password@127.0.0.1:1521/orcl schemas=user dumpfile=database.dmp logfile=export_log.log directory=DUMP_DIR

导入:

impdp user/password@127.0.0.1/orcl schemas=user dumpfile=database.dmp logfile=import_log.log directory=DUMP_DIR remap_tablespace=oldtablespace:newtablespace remap_schema=user:user table_exists_action=replace

参数解释

exp:导出命令,导出时必写。

imp:导入命令,导入时必写,每次操作,二者只能选择一个执行。

username:导出数据的用户名,必写;

password:导出数据的密码,必写;

@:地址符号,必写;

SERVICENAME:Oracle的服务名,必写;

1521:端口号,1521是默认的可以不写,非默认要写;

schemas:导出操作的用户名;

dumpfile:导出的文件;

logfile:导出的日志文件,可以不写;

directory:创建的文件夹名称;

remap_schema=源数据库用户名:目标数据库用户名,二者不同时必写,相同可以省略;

remap_tablespace=源数据库表空间:目标数据库表空间,可以实现不同表空间的导入

table_exists_action:表存在时的处理方法

1)skip:默认操作

2)  replace:先drop表,然后创建表,最后插入数据

3)  append:在原来数据的基础上增加数据

4)  truncate:先truncate,然后再插入数据

注:目标用户不存在时也可以导入,会自动新建与源用户权限相同的用户

查看表空间:
select * from dba_tablespaces;

查看管理员目录(同时查看操作系统是否存在,因为Oracle并不关心该目录是否存在,如果不存在,则出错)。
select * from dba_directories;

创建逻辑目录,该命令不会在操作系统创建真正的目录,最好以system等管理员创建。 
create directory testdata as 'd:\test\dump';

给test用户赋予在指定目录的操作权限,最好以system等管理员赋予。
grant read,write on directory testdata to test;

开启并行:

nohup expdp tyjt/tyjt@tyjtdb directory=db_bak dumpfile=tyjt_20220417_%U.dmp logfile=tyjt_20220417.log parallel=4 schemas=tyjt &

nohup impdp tyjt/Tyjt#20220313@tyjtdb directory=db_bak dumpfile=tyjt_20220417_%U.dmp logfile=tyjt_20220417dr.log  parallel=4 schemas=tyjt remap_schema=tyjt:tyjt transform=oid:n &

_%U为固定形式,开启并行后会根据开启的并行生成多个dump文件

parallel为并行数,导出时开启几个并行,导入时就开启同样的并行。

transform=oid:n #oid为Y时在导入过程中将分配一个新的oid给对象表

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值