95.You have a large amount of historical data in a flat file. Some analysts in your organization nee

95.You have a large amount of historical data in a flat file. Some analysts in your organization need to
query this data in the file. The file is too large to load the data in it into your current database.
Which is the most effective method to access this data in your database?
A.Use the database link.
B.Use the SQL*Loader utility.
C.Use the Oracle Data Pump utility.
D.Create an external table and leave the data in the flat file.
答案:D
解析:题目说是文件特别大,对于导入数据库很困难,还可以使用什么方法,这个肯定是使用外部表了
1.建立数据文件目录及日志目录
  create directory data_dir as '/home/dwj/data_dir';
  create directory log_dir  as '/home/dwj/log_dir';
  grant read on  directory data_dir to bk;
  grant write on  directory log_dir  to bk;
2. 查看是否具有权限
SQL> select * from dba_tab_privs where table_name in ('DATA_DIR','LOG_DIR') and grantee='BK'


GRANTEE    OWNER      TABLE_NAME GRANTOR    PRIVILEGE            GRA HIE
---------- ---------- ---------- ---------- -------------------- --- ---
BK         SYS        LOG_DIR    SYS        WRITE                NO  NO
BK         SYS        DATA_DIR   SYS        READ                 NO  NO
3.创建外部表
create table test_delta
(id varchar2(100))
organization external              --说明这个是一个外部表
(type oracle_loader                --使用的驱动器程序为oracle_loader,这个是oracle自带的
default directory DATA_DIR         --默认的数据文件路径为DATA_DIR
access parameters                  --后面定义访问参数 
(records delimited by newline characterset us7ascii --记录用换行符分割,字符集为US7ASCII
badfile 'LOG_DIR':'test.bad'       --外表的坏文件存放的位置 
logfile 'LOG_DIR':'test.log'       --外表的日志文件存放的位置 
fields terminated by " " optionally enclosed by '\t'  --字段由空格或者\t来进行分割
)
location('test_delta.txt')         --数据文件名 
)
reject limit unlimited;            --读取整个数据文件的数据

你可能感兴趣的:(1z0-052)