table_exists_action=append和table_exists_action=truncate

table_exists_action=append和table_exists_action=truncate

一、环境准备

1.1 192.168.1.22上创建single01.student表

SQL> select * from single01.student;

        ID       NAME
------------    --------------------------------------------------------------------
         1       xiaoming

expdp导出该表

mkdir -p /backup/expdp0522
create or replace directory dir_dump as '/u01/app/oracle/exp';

expdp  \"/ as sysdba\"  directory=dir_dump dumpfile=u_single01_202205_%U.dump parallel=2 logfile=u_single01_202205.log schemas=single01

impdp在192.168.1.67中导入该表

export ORACLE_SID=jdedb1
impdp \"/ as sysdba\" directory=dir_dump dumpfile=u_single01_202205_%U.dump parallel=2 schemas=single01   logfile=u_single01_202205.log

在192.168.1.67目标端上,

SQL> select * from single01.student;
        ID NAME
---------- --------------------
         1 xiaoming

二、验证append参数

1.修改源库数据

SQL> select * from single01.student;

        ID NAME
---------- --------------------
         1 xiaomingming
         2 xiaozhang

2.导出后导入:

impdp \"/ as sysdba\" directory=dir_dump dumpfile=u_student_01modify_202205_%U.dump parallel=2 tables=single01.student  logfile=u_student_01_202205.log table_exists_action=append

在192.168.1.67目标端上,

SQL> select * from single01.student;
        ID NAME
---------- --------------------
         1 xiaoming
         1 xiaomingming
         2 xiaozhang

可以看见,对不impdp之前得数据,参数append不能分辨已有数据,而是直接在后面全表追加

三、验证truncate参数

1.修改源库数据

SQL> update single01.student set name='xiaozhangzhang' where id=2;

1 row updated.

SQL> insert into single01.student values(3,'xiaoli');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from single01.student;

        ID  NAME
---------- ----------------------------------------------------------------------
         1  xiaomingming

         2  xiaozhangzhang

         3  xiaoli

2.导出后导入数据

expdp  \"/ as sysdba\"  directory=dir_dump dumpfile=u_student_02modify_202205_%U.dump parallel=2 logfile=u_student_02modify_202205.log tables=single01.student
impdp \"/ as sysdba\" directory=dir_dump dumpfile=u_student_02modify_202205_01.dump parallel=2 tables=single01.student   logfile=u_student_02_202205.log table_exists_action=truncate

此时在192.168.1.67目标端上检查

SQL> select * from single01.student;

        ID  NAME
---------- ----------------------------------------------------------------------
         1  xiaomingming

         2  xiaozhangzhang

         3  xiaoli

truncate参数是删除目标端67上得原有数据,再将新数据导入

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值