简体   繁体   English

oracle使用sql加载器加载数据时忽略列值中的空间

[英]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.

相关问题 使用sql loader将数据从CSV文件加载到oracle表 - Loading data from CSV file to oracle table using sql loader 在使用oracle apex加载数据时,我应该查找其他表以匹配id并提取列值 - While data loading using oracle apex i should lookup to other table for matching id and pull a column value 加载非常大的日志文件时,Oracle SQL loader错误 - Oracle SQL loader Error while loading really huge log files Oracle SQL 加载程序不会加载数据,而 INSERT 可以(日期列,ORA-01858) - Oracle SQL Loader won't load data while INSERT can (date column, ORA-01858) 使用Oracle SQL loader加载时出错 - Error loading with Oracle sql loader 使用 SQL Loader 在表中加载数据 - loading data in table using SQL Loader 使用pentaho数据集成器时从SQL Server表的varchar(max)列加载Oracle表中的clob列时提高性能 - Improving performance while loading clob column in an Oracle table from a varchar(max) column in a SQL Server table when using pentaho data integrator 使用 Oracle SQL Loader (sqlldr) 加载数据时的乱码归档值 - Gibberish filed values when Loading data with Oracle SQL Loader (sqlldr) 使用 SQL 加载程序加载文件时如何在列中保留双引号 - How to retain double quotes in a column while loading a file using SQL Loader oracle sql loader在同一表的不同列中加载数据 - oracle sql loader loading data in different columns in same table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM