89ou 发表于 2015-11-9 13:12:33

[每日一题] 11gOCP 1z0-052 :2013-09-7 The usage of the SQL*LOAD utility...........

  

转载请注明出处:http://blog.iyunv.com/guoyjoe/article/details/11358497



  
   正确答案:AB
  
  SQL*Loader加载数据从外部文件到Oracle数据库表。它有一个强大的数据解析引擎,用控制文件把数据文件中的数据按一定的格式做限制加载到数据库的表中。以下是使用SQL*Loader特点:
  1、通过网络加载数据。这表示您可以在客户端运行SQL*Loader加载数据到数据库服务器端。
  2、在同一会话下可以从多个数据文件来完成数据加载。
  3、在同一会话下数据可以加载到多个表。
  4、指定字符集的数据。
  5、选择性地加载数据(你可以基于记录的值加载记录)。
  6、使用SQL函数加载数据。
  7、在指定的字段中产生唯一的序列的键值。
  8、把操作系统的文件数据当成数据库中表的数据来访问。
  9、数据可以从磁盘、磁带或命名管道加载。
  10、可以生成详细的错误报告,这大大帮助多们快速找到故障原因。
  11、可以加载任何复杂的对象关系数据。
  12可以使用二次数据文件来完成加载lob和集合。
  无论是常规使用或直接路径加载。而传统的路径加载非常灵活,直接路径加载提供了优越的加载性能。
  
  解析答案:
  答案A正确,同一个数据文件可以加载到多个表,实验如下
  (1)创建两张表

gyj@OCM> create table gyj_test1 (xm varchar2(20),sfzh varchar2(20));
Table created.
gyj@OCM> create table gyj_test2 (xm varchar2(20),sfzh varchar2(20));
Table created.

  (2)文件中的数据

$vi /home/oracle/gyj_test.dat
A Joe 433101196303180048
B Tom 432325197810254019

  (3)控制文件

$ vi /home/oracle/gyj_test.ctl
load data
infile '/home/oracle/gyj_test.dat'
discardfile gyj_test.dat.dsc
into tablegyj_test1
when tab='A'
(tab filler position(1:1),
xm position(3:5),
sfzh position(*+1:24)
)
into tablegyj_test2
when tab='B'
(tab filler position(1:1),
xm position(3:5),
sfzh position(*+1:24)
)

  (4)加载数据

oracle@mydb ~]$ sqlldr userid=gyj/gyj control=/home/oracle/gyj_test.ctl
SQL*Loader: Release 11.2.0.3.0 - Production on Tue Sep 10 13:08:38 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.All rights reserved.
Commit point reached - logical record count 2

  (5)验证两表的数据

gyj@OCM> select * from gyj_test1;
XM                   SFZH
-------------------- --------------------
Joe                  433101196303180048
gyj@OCM> select * from gyj_test2;
XM                   SFZH
-------------------- --------------------
Tom                  432325197810254019

  答案B正确,多个数据文件的数据可以加载到同一张表,实验如下:
  (1)创建两张表
  

gyj@OCM> create table gyj_test3 (xm varchar2(20),sfzh varchar2(20));
Table created.

  
  (2)文件中的数据

$vi /home/oracle/gyj_test1.dat
Joe|433101196303180048
$vi /home/oracle/gyj_test2.dat
Tom|432325197810254019

  (3)控制文件

$ vi /home/oracle/gyj_test3.ctl
load data
infile '/home/oracle/gyj_test1.dat'
infile '/home/oracle/gyj_test2.dat'
into tablegyj_test3
fields terminated by '|'
(xm,sfzh)

  (4)加载数据

$ sqlldr userid=gyj/gyj control=/home/oracle/gyj_test3.ctl
SQL*Loader: Release 11.2.0.3.0 - Production on Tue Sep 10 13:16:13 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.All rights reserved.
Commit point reached - logical record count 1
Commit point reached - logical record count 2



  (5)验证这张表的数据

gyj@OCM> select * from gyj_test3;
XM                   SFZH
-------------------- --------------------
Joe                  433101196303180048
Tom                  432325197810254019

  答案C不正确,是可以按记录来导的,比如以下实验,我只导后两条记录
  (1)创建一张表

gyj@OCM> create table gyj_test4 (xm varchar2(20),sfzh varchar2(20));
Table created.

  (2)文件中的数据

$ vi /home/oracle/gyj_test4.dat
Tom|432325197810254019|
Joe|433101196303180048|
Rose|433101195709120024|
Jack|43310119691229004x|
Linda|433101196711270050|
Jeny|433101197306101514|

  (3)控制文件

$ vi /home/oracle/gyj_test4.ctl
load data
infile '/home/oracle/gyj_test4.dat'
into tablegyj_test4
fields terminated by '|'
(xm,sfzh)

  (4)加载数据

$ sqlldr userid=gyj/gyj control=/home/oracle/gyj_test4.ctl skip=3
SQL*Loader: Release 11.2.0.3.0 - Production on Tue Sep 10 13:33:25 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.All rights reserved.
Commit point reached - logical record count 3
gyj@OCM> select * from gyj_test4;

  (5)验证这张表的数据

XM                   SFZH
-------------------- --------------------
Jack               43310119691229004x
Linda                433101196711270050
Jeny               433101197306101514



  答案D明显不正确这里不再解释了
  答案E不正确: 数据可以从磁盘、磁带或命名管道加载
  


  
  QQ:252803295
  技术交流QQ群:

DSI&Core SearchⅠ 群:127149411(2000人技术群:未满)

DSI&Core SearchⅡ 群:177089463(1000人技术群:未满)

DSI&Core SearchⅢ 群:284596437(500人技术群:未满)

DSI&Core SearchⅣ 群:192136702(500人技术群:未满)

DSI&Core SearchⅤ 群:285030382(500人闲聊群:未满)


  
  


  MAIL:dbathink@hotmail.com
  BLOG: http://blog.iyunv.com/guoyjoe
  WEIBO:http://weibo.com/guoyJoe0218
  ITPUB: http://www.itpub.net/space-uid-28460966.html
  OCM:   http://education.oracle.com/education/otn/YGuo.HTM





版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: [每日一题] 11gOCP 1z0-052 :2013-09-7 The usage of the SQL*LOAD utility...........