Oracle Sql Loader 将 csv 中的字符串值“330,000.00”转换为具有列 Capital 数据类型编号的表以存储 330000.00

问题描述 投票:0回答:1
OPTIONS (SKIP=1)
LOAD DATA
INFILE *
APPEND INTO TABLE test_table
FIELDS TERMINATED BY ',' 
TRAILING NULLCOLS
(
    CAPITAL FLOAT "replace(:CAPITAL, ',', '')"
)

我尝试使用sql加载器将数据插入表中,我的csv数据是“330,000.00”,我需要的是330000.00,但只有330被插入,为我提供了找到预期输出的解决方案

sql oracle oracle11g oracle-sqldeveloper sql-loader
1个回答
0
投票

目标表:

SQL> create table test (capital number);

Table created.

控制文件(底部包含示例数据):

load data
infile *
replace
into table test
fields terminated by whitespace
( capital "to_number(:capital, '999,999,999.99')"
)

begindata
300,000.00
24,435.53
1,374,992.02

加载会话:

SQL> $sqlldr scott/tiger@pdb1 control=test17.ctl log=test17.log

SQL*Loader: Release 21.0.0.0.0 - Production on Mon Apr 1 09:38:48 2024
Version 21.3.0.0.0

Copyright (c) 1982, 2021, Oracle and/or its affiliates.  All rights reserved.

Path used:      Conventional
Commit point reached - logical record count 2
Commit point reached - logical record count 3

Table TEST:
  3 Rows successfully loaded.

Check the log file:
  test17.log
for more information about the load.

SQL>

结果:

SQL> select * from test;

   CAPITAL
----------
    300000
  24435.53
1374992.02

SQL>
© www.soinside.com 2019 - 2024. All rights reserved.