我正在使用SQL * Loader将CSV文件数据加载到名为EMPLOYEE的表中。
我的CSV文件数据用竖线(|)分隔:
EMPID|EMPNAME_ADDRESS|SALARY|GRADE
123|Rams Hyd|1000|A1
124|Sand MUM|2,000|A2
125|"PRASANNA qwer trasf\"501 advv vvd, qee ggg\trfe \411005 THE|3,00,000|A3
我的控制文件是:
LOAD DATA
Insert INTO TABLE EMPLOYEE
Fields terminated by "|" Optionally enclosed by '"' TRAILING NULLCOLS
(
EMPID,
EMPNAME,
SALARY,
GRADE
)
当我使用上述控制文件加载数据时,前两个记录加载正常,而对于第三条记录,我收到如下所述的错误。
no terminator found after TERMINATED and ENCLOSED field
请建议进行更改以正确加载数据。
答案 0 :(得分:0)
这是一种加载此类数据的方法。
首先,有一个目标表(我希望它有意义;您应该已经提供了它):
SQL> create table employee
2 (empid number,
3 empname varchar2(200),
4 salary number,
5 grade varchar2(10)
6 );
Table created.
SQL>
控制文件:请注意SKIP
选项(跳过标题行),以及SALARY列的REPLACE
函数调用(以删除格式为的多余逗号内容;稍后在 presentation 层中添加它们。
options (skip = 1)
load data
infile *
replace
into table employee
fields terminated by "|" TRAILING NULLCOLS
(
empid,
empname,
salary "replace(:salary, ',', null)",
grade)
begindata
EMPID|EMPNAME_ADDRESS|SALARY|GRADE
123|Rams Hyd|1000|A1
124|Sand MUM|2,000|A2
125|"PRASANNA qwer trasf\"501 advv vvd, qee ggg\trfe \411005 THE|3,00,000|A3
加载会话:
SQL> $sqlldr scott/tiger control=test06.ctl log=test06.log
SQL*Loader: Release 11.2.0.2.0 - Production on Uto Tra 9 19:37:46 2019
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 2
Commit point reached - logical record count 3
SQL> select * From employee;
EMPID EMPNAME SALARY GRADE
---------- ---------------------------------------- ---------- ----------
123 Rams Hyd 1000 A1
124 Sand MUM 2000 A2
125 "PRASANNA qwer trasf\"501 advv vvd, qee 300000 A3
ggg\trfe \411005 THE
SQL>