加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

oracle impdp导入的问题

(2012-02-06 17:08:32)
标签:

杂谈

分类: oracle技术
刚刚看到有人问了这样一个问题,
导入数据不导入索引怎么实现?
我回答 可以考虑使用exclude,
他又问,如果表存在怎么办?
content=data_only 加上这个子句

我做了一个小的实验,大概的模拟了一下。

SQL> show user
USER is "SCOTT"
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
DEPT                           TABLE
EMP                            TABLE
BONUS                          TABLE
SALGRADE                       TABLE
SYS_TEMP_FBT                   TABLE
                             TABLE
                             TABLE
DEMO                           TABLE
S_TEST                         TABLE

9 rows selected.

SQL>
SQL>
SQL>
SQL> create table imptest as select empno,ename,sal from emp;

Table created.

SQL> create index ename_idx on imptest(ename);

Index created.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@ztj10 ~]$ expdp scott/tiger directory=udir dumpfile=a.dmp tables=imptest

Export: Release 10.2.0.1.0 - Production on Monday, 06 February, 2012 17:01:52

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "SCOTT"."SYS_EXPORT_TABLE_01":  scott/******** directory=udir dumpfile=a.dmp tables=imptest
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/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
. . exported "SCOTT"."IMPTEST"                           5.851 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/udir/a.dmp
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 17:02:55

[oracle@ztj10 ~]$ sqlplus scott/tiger

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 6 17:03:14 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> drop table imptest purge;

Table dropped.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

[oracle@ztj10 ~]$ impdp scott/tiger directory=udir dumpfile=a.dmp exclude=INDEX:"IN('ENAME_IDX')"

Import: Release 10.2.0.1.0 - Production on Monday, 06 February, 2012 17:07:52

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01":  scott/******** directory=udir dumpfile=a.dmp exclude=INDEX:IN('ENAME_IDX')
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."IMPTEST"                           5.851 KB      14 rows
Job "SCOTT"."SYS_IMPORT_FULL_01" successfully completed at 17:07:59

[oracle@ztj10 ~]$ sqlplus scott/tiger

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 6 17:08:10 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select * from imptest
  ;

     EMPNO ENAME             SAL
---------- ---------- ----------
      7369 SMITH            1000
      7499 ALLEN            1600
      7521 WARD             1250
      7566 JONES            2975
      7654 MARTIN           1250
      7698 BLAKE            2850
      7782 CLARK            2450
      7788 SCOTT            3000
      7839 KING             5000
      7844 TURNER           1500
      7876 ADAMS            1100
      7900 JAMES             950
      7902 FORD             2000
      7934 MILLER           1300

14 rows selected.

SQL> select index_name,table_name from user_indexes where table_name='IMPTEST';

no rows selected

[oracle@ztj10 ~]$ impdp scott/tiger directory=udir dumpfile=a.dmp exclude=INDEX:"IN('ENAME_IDX')" contents=data_only
LRM-00101: unknown parameter name 'contents'

[oracle@ztj10 ~]$ impdp scott/tiger directory=udir dumpfile=a.dmp exclude=INDEX:"IN('ENAME_IDX')" content=data_only

Import: Release 10.2.0.1.0 - Production on Monday, 06 February, 2012 17:16:48

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01":  scott/******** directory=udir dumpfile=a.dmp exclude=INDEX:IN('ENAME_IDX') content=data_only
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."IMPTEST"                           5.851 KB      14 rows
Job "SCOTT"."SYS_IMPORT_FULL_01" successfully completed at 17:16:58


SQL> conn scott/tiger
Connected.
SQL> select * from imptest;

     EMPNO ENAME             SAL
---------- ---------- ----------
      7369 SMITH            1000
      7499 ALLEN            1600
      7521 WARD             1250
      7566 JONES            2975
      7654 MARTIN           1250
      7698 BLAKE            2850
      7782 CLARK            2450
      7788 SCOTT            3000
      7839 KING             5000
      7844 TURNER           1500
      7876 ADAMS            1100
      7900 JAMES             950
      7902 FORD             2000
      7934 MILLER           1300
      7369 SMITH            1000
      7499 ALLEN            1600
      7521 WARD             1250
      7566 JONES            2975
      7654 MARTIN           1250
      7698 BLAKE            2850
      7782 CLARK            2450
      7788 SCOTT            3000
      7839 KING             5000
      7844 TURNER           1500
      7876 ADAMS            1100
      7900 JAMES             950
      7902 FORD             2000
      7934 MILLER           1300

28 rows selected.


0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有