Oracle,如何在 SQL 加载的插入数据中包含分隔符?
How to include a separator in the inserted data in SQL load, Oracle?
load data
infile 'c:\oracle_toad\sql_loader\v1_data.txt'
replace into table v1 fields terminated by ','
( a integer external, b char, c char )
1,2,"da,ta1"
2,4,"dat,a2"
2,4,"da,ta2"
"" are not supposed to be inserted as a part of data. That's just for reference.
我故意在每个数据集中插入了“,”。
我希望像这样插入 1, 2, "da,ta1" <<<。有没有一种方法可以在数据集中包含分隔符“,”?
这是一个例子:
测试table:
SQL> create table test (col1 number, col2 varchar2(20), col3 varchar2(20));
Table created.
控制文件:
load data
infile *
replace
into table test
fields terminated by ',' optionally enclosed by '"'
trailing nullcols
(
col1,
col2,
col3
)
begindata
1,2,"da,ta1"
2,4,"dat,a2"
2,4,"da,ta2"
正在加载会话和结果:
SQL> $sqlldr scott/tiger control=test04.ctl log=test04.log
SQL*Loader: Release 11.2.0.2.0 - Production on Pon Kol 27 14:11:26 2018
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 test;
COL1 COL2 COL3
---------- -------------------- --------------------
1 2 da,ta1
2 4 dat,a2
2 4 da,ta2
SQL>
load data
infile 'c:\oracle_toad\sql_loader\v1_data.txt'
replace into table v1 fields terminated by ','
( a integer external, b char, c char )
1,2,"da,ta1"
2,4,"dat,a2"
2,4,"da,ta2"
"" are not supposed to be inserted as a part of data. That's just for reference.
我故意在每个数据集中插入了“,”。 我希望像这样插入 1, 2, "da,ta1" <<<。有没有一种方法可以在数据集中包含分隔符“,”?
这是一个例子:
测试table:
SQL> create table test (col1 number, col2 varchar2(20), col3 varchar2(20));
Table created.
控制文件:
load data
infile *
replace
into table test
fields terminated by ',' optionally enclosed by '"'
trailing nullcols
(
col1,
col2,
col3
)
begindata
1,2,"da,ta1"
2,4,"dat,a2"
2,4,"da,ta2"
正在加载会话和结果:
SQL> $sqlldr scott/tiger control=test04.ctl log=test04.log
SQL*Loader: Release 11.2.0.2.0 - Production on Pon Kol 27 14:11:26 2018
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 test;
COL1 COL2 COL3
---------- -------------------- --------------------
1 2 da,ta1
2 4 dat,a2
2 4 da,ta2
SQL>