[英]ignore space in column value while loading data using sql loader by oracle
I am trying to load data using oracle sql loader and using space as separator of columns but I am facing problem that one of the columns value including space, I need your support to avoid considering this space as column separator.我正在尝试使用 oracle sql loader 加载数据并使用空格作为列的分隔符,但我面临的问题是其中一个列值包括空格,我需要您的支持以避免将此空格视为列分隔符。
I tried to use regexp_replace and replace functions我尝试使用 regexp_replace 并替换函数
DSTCOUNTRY " REGEXP_REPLACE(:DSTCOUNTRY,'dstcountry=','')",
the column value is: dstcountry="United States"
列值为:
dstcountry="United States"
and the expecting value to be stored in the table is: United States
并且要存储在表中的期望值为:
United States
The sql loader command is: load data infile 'in' append into table test_table fields terminated by " " optionally enclosed by '"' TRAILING NULLCOLS DSTCOUNTRY " REPLACE(:DSTCOUNTRY,'dstcountry=','')", sql 加载器命令是:将数据 infile 'in' append into table test_table 字段以“”结尾,可选地用 '"' TRAILING NULLCOLS DSTCOUNTRY " REPLACE(:DSTCOUNTRY,'dstcountry=','')",
I am using oracle 10G and 12C.我正在使用 oracle 10G 和 12C。
According to what you posted so far, it is optionally enclosed
you're looking for.根据您到目前为止发布的内容,它可以
optionally enclosed
您正在寻找的内容。 Here's an example.这是一个例子。
Test table:测试表:
SQL> create table test (id number, dstcountry varchar2(20));
Table created.
Control file (contains sample data as well):控制文件(也包含样本数据):
load data
infile *
replace
into table test
fields terminated by " "
optionally enclosed by '"'
trailing nullcols
(
id,
dstcountry)
begindata
123 "Croatia"
125 "United States"
Loading session and result:加载会话和结果:
SQL> $sqlldr scott/tiger control=test08.ctl log=test08.log
SQL*Loader: Release 11.2.0.2.0 - Production on Pon Srp 22 17:59:23 2019
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 1
Commit point reached - logical record count 2
SQL> select * from test;
ID DSTCOUNTRY
---------- --------------------
123 Croatia
125 United States
SQL>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.