无法使用外部 table 加载数据

Unable to load data using external table

我正在尝试从 csv 文件加载外部 table 中的数据。 以下是我的片段:

create table emp_ext
(
eid number,ename char(9)
)
organization external
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY test
ACCESS PARAMETERS
       (
       RECORDS DELIMITED BY NEWLINE
       FIELDS TERMINATED BY ','
       (
       eid number,
       ename char(9)
       )

       )
       LOCATION('C:\Users002971\Desktop\empf.csv')
)

create directory test as 'C:\Users002971\Desktop'
grant read on directory test to matuat35 // granted using another user

当我从 emp_ext 执行 select * 时,出现以下错误:

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 ""identifier:expecting one of :"binary_float,binary_double,comma,char,date,double"
KUP-01008:the bad identifier was double
KUP-01007:at line 4 column 12

请帮忙

datatype_spec section of the external table documenation 表明加载程序驱动程序无法识别 number。在您的代码中,它被视为标识符而不是数据类型,因此出现错误。

您可以使用 oracle_numberunsigned integer,因为它可能始终是员工 ID 的正整数;或者保持无类型并允许隐式转换为 table 列类型。

你的location也应该只指定目录内的文件名,而不是完整路径:

create table emp_ext
(
eid number,ename varchar2(15)
)
organization external
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY test
ACCESS PARAMETERS
       (
       RECORDS DELIMITED BY NEWLINE
       FIELDS TERMINATED BY ','
       (
       eid unsigned integer external(9),
       ename char(15)
       )

       )
       LOCATION('empf.csv')
)

或更简单,但依赖于隐式转换:

...
ACCESS PARAMETERS
       (
       RECORDS DELIMITED BY NEWLINE
       FIELDS TERMINATED BY ','
       (
       eid,
       ename char(15) rteim
       )

       )
       LOCATION('empf.csv')
)