一、官方文档
TABLE_EXISTS_ACTION
二、 适用场景
导入表时,表已存在,根据参数来选择处理方法。
三、参数选项
TABLE_EXISTS_ACTION=[SKIP | APPEND | TRUNCATE | REPLACE]
1. SKIP: 直接跳过,进行下一个对象操作。(默认)
2. APPEND: 在原有数据基础上继续追加
3. TRUNCATE: 先TRUNCATE,再完成数据插入
4. REPLACE: 先DROP表,然后创建表,最后完成数据插入
四、实验
1. 准备环境
(1) 用原有的SCOTT用户下的EMP表
scott@ORCL>select count(*) from emp;
COUNT(*)
----------
14
(2) 创建directory导出目录并赋权
sys@ORCL>create directory dump_dir as '/home/oracle/test';
Directory created.
sys@ORCL>grant write,read on directory dump_dir to public;
(3) 建立操作系统目录
[oracle@test ~]$ pwd
/home/oracle
[oracle@test ~]$ mkdir test
2. EXPDP导出emp表数据,加入两条数据,再次导出。
(1)导出源表数据
[oracle@test ~]$ expdp scott/tiger directory=dump_dir tables=emp dumpfile=expdat.dmp
Export: Release 11.2.0.1.0 - Production on Tue Jul 14 15:36:27 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/******** directory=dump_dir tables=emp
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SCOTT"."EMP" 8.570 KB 14 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
/home/oracle/test/expdat.dmp
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 15:36:37
(2) 加两条数据
INSERT INTO "SCOTT"."EMP" (EMPNO, ENAME, JOB, MGR, SAL, DEPTNO) VALUES (