zoukankan      html  css  js  c++  java
  • 【练习】移动数据----infile *

    要求:

    ①指定bad文件;

    ②挂在之前将目标表delete;

    ③导入的的数据在控制文件中。

    1.创建目录对象:

    13:05:24 SYS@ORA11GR2>create or replace directory dir_dt as '/home/oracle';
    
    Directory created.

    2.将读写权限给scott用户:

    13:05:28 SYS@ORA11GR2>grant read,write on directory dir_dt to scott;
    
    Grant succeeded.

    3.scott用户下创建测试表:

    13:07:17 SYS@ORA11GR2>conn scott/tiger
    Connected.
    13:07:57 SCOTT@ORA11GR2>create table s1_base(id number(5),fname varchar2(10),lname varchar2(10));
    
    Table created.

    4.创建控制文件:

    [oracle@host03 ~]$ vi base.ctl
    load data
    infile *
    badfile 'base.bad'
    into table s1_base
    replace
    fields terminated by ','
    (id,fname,lname)
    begindata
    1,zhangfei,zhangyunde
    2,guanyun,guanyunchang
    3,liubei,liuxuande

    5.通过sqlldr将控制文件的数据导入scott用户下的测试表

    [oracle@host03 ~]$ sqlldr scott/tiger control=base.ctl
    
    SQL*Loader: Release 11.2.0.4.0 - Production on Fri Nov 11 13:09:59 2016
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 3

    6.查看生成的相关日志:

    [oracle@host03 ~]$ ll
    total 12
    -rw-r--r-- 1 oracle oinstall   23 Nov 11 13:10 base.bad
    -rw-r--r-- 1 oracle oinstall  181 Nov 11 13:09 base.ctl
    -rw-r--r-- 1 oracle oinstall 1698 Nov 11 13:10 base.log

    7.查看bad文件:

    [oracle@host03 ~]$ cat base.bad
    2,guanyun,guanyunchang

    8.查看导入数据:

    13:08:39 SCOTT@ORA11GR2>select * from s1_base;
    
            ID FNAME      LNAME
    ---------- ---------- ----------
             1 zhangfei   zhangyunde
             3 liubei     liuxuande
  • 相关阅读:
    FindBugs详解
    Java杂项
    Ubuntu 16.04安装DB2 Express C v11.1
    h5搜索功能
    与安卓交互的上传图片 与 上传语音、视频
    获取后台轮播图图片,让其自动播放
    点赞和关注功能
    split、replace、indexof、substr 用法 (获取后台富文本框内容,截取图片)
    ttyu平台进页面获取阅读量
    图片放大预览功能
  • 原文地址:https://www.cnblogs.com/tomatoes-/p/6186968.html
Copyright © 2011-2022 走看看