在Oracle中加载文件时出错

时间:2014-07-10 14:04:02

标签: sql oracle

我一直在尝试使用SQL loader在oracle数据库中加载文本文件。 请在下面找到我的问题: -

CREATE TABLE test_test
 ( 
numb int
 )
ORGANIZATION EXTERNAL
 (
  TYPE ORACLE_LOADER
  DEFAULT DIRECTORY dir_test
  ACCESS PARAMETERS 
   (
    RECORDS DELIMITED BY NEWLINE 
  BADFILE 'testscript.bad'
  DISCARDFILE 'testscript.dis'
  LOGFILE 'testscript.log'
  SKIP 0
         (
            numb int
)
   )
  LOCATION (dir_test:'test.txt')
 )
REJECT LIMIT 0
PARALLEL (DEGREE DEFAULT INSTANCES DEFAULT)
NOMONITORING;

但是,当我尝试select * from test_test时,我收到以下错误:

 ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "(": expecting one of: "badfile, byteordermark,
    characterset, data, delimited, discardfile, exit, fields, fixed, load, logfile,
    nodiscardfile, nobadfile, nologfile, date_cache, processing, readsize, string,
    skip, variable"
    KUP-01007: at line 6 column 10
    ORA-06512: at "SYS.ORACLE_LOADER", line 14
    ORA-06512: at line 1

请建议这可能的原因是什么?我试图在unix环境中的sqlplus上运行它。 dir_test是我之前创建的oracle目录

1 个答案:

答案 0 :(得分:0)

fields之前您遗漏了关键字(numb int),此处int无效。

CREATE TABLE test_test (numb int)
  ORGANIZATION EXTERNAL (
    TYPE ORACLE_LOADER
    DEFAULT DIRECTORY dir_test
    ACCESS PARAMETERS (
      RECORDS DELIMITED BY NEWLINE
      BADFILE 'testscript.bad'
      DISCARDFILE 'testscript.dis'
      LOGFILE 'testscript.log'
      SKIP 0
      FIELDS (numb integer))
    LOCATION (dir_test:'test.txt'))
  REJECT LIMIT 0
  PARALLEL (DEGREE DEFAULT INSTANCES DEFAULT)
  NOMONITORING;