ITPub博客

首页 > 数据库 > Oracle > 利用ORACLE_DATAPUMP为驱动创建外部表

利用ORACLE_DATAPUMP为驱动创建外部表

原创 Oracle 作者:skyin_1603 时间:2016-09-30 00:44:22 0 删除 编辑
利用ORACLE_DATAPUMP为驱动创建外部表首先要确定将要用那个表来卸载,本次就选用scott用户下的dept表,作为下载表。
1、先让我们看看dept表的结构:
desc dept
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
DEPTNO                                    NOT NULL NUMBER(2)
DNAME                                              VARCHAR2(14)
LOC                                                VARCHAR2(13)

2、查看dept表数据:select * from dept;
  DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON

3、接着,创建存放外部表的系统存储目录与目录对象:
创建目录对象dir_home,映射至操作系统目录/home/oracle,并将读、写的权限赋予SCOTT用户

    SQL> create or replace directory dir_home as '/home/oracle';
    Directory created.
     SQL> grant read,write on directory dir_home to scott;
     Grant succeeded.
4、oracle_DATAPUMP为驱动创建外部表卸载scott下的dept表的策略:
SOL> create table extadd_dept(deptno,dname,loc)
2 organization external
3 (
4 type oracle_datapump
5 default directory dir_home
6 location ('ext1.csv')
7 )
8 as select * from scott.dept;

5、到操作系统的目录对象所在的路径查看由scott下的dept表卸载的外部表:
[oracle@enmo ~]$ ll
total 444
drwxr-xr-x 2 oracle oinstall   4096 Sep 24 23:14 data
drwxr-xr-x 2 oracle oinstall   4096 Sep 24 19:49 datadump
-rw-r--r-- 1 oracle oinstall   1937 Sep 26 15:08 export.log
drwxr-xr-x 2 oracle oinstall   4096 Sep 26 15:43 ext
-rw-r----- 1 oracle oinstall  12288 Sep 26 15:48 ext1.csv
-rw-r--r-- 1 oracle oinstall     82 Sep 26 15:50 EXTADD_DEPT_11017.log
-rw-r--r-- 1 oracle oinstall     41 Sep 26 22:00 EXTADD_DEPT_12220.log
-rw-r--r-- 1 oracle oinstall   1648 Sep 26 15:25 import.log
drwxr-xr-x 2 oracle oinstall   4096 Sep 28 22:14 rec
-rw-r----- 1 oracle oinstall 286720 Sep 26 15:08 scott.dmp
-rw-r--r-- 1 oracle oinstall    303 Sep 24 22:30 t.ctl
-rw-r--r-- 1 oracle oinstall   1459 Sep 24 22:47 t.log
-rw-r----- 1 oracle oinstall 106496 Sep 25 10:26 ts_ora11gr2.dmp
[oracle@enmo ~]$ 

6、通过卸载的外部表,查看原来Scott用户表的dept的数据:
SQL> select * from exttab;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 CCOUNTING      NEW YORK
        50 MANA           BEIJING
        20 ESEARCH        DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON

外部表卸载成功。


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31392094/viewspace-2125777/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2016-09-06

  • 博文量
    231
  • 访问量
    215147