外部 table 在从文件读取时截断尾随空格
External table truncates trailing whitespace while reading from file
我正在尝试将文件内容加载到外部 table。执行此操作时,尾随 space 会被截断。
'CREATE TABLE ' || rec.ext_table_name || ' (ROW_DATA VARCHAR2(4000)) ORGANIZATION EXTERNAL ' ||
'(TYPE ORACLE_LOADER DEFAULT DIRECTORY ' || rec.dir_name || ' ACCESS ' || 'PARAMETERS (RECORDS ' ||
'DELIMITED by NEWLINE NOBADFILE NODISCARDFILE ' ||
'FIELDS REJECT ROWS WITH ALL NULL FIELDS (ROW_DATA POSITION(1:4000) char)) LOCATION (' || l_quote ||
'temp.txt' || l_quote || ')) REJECT LIMIT UNLIMITED'
例如,B
表示空白 space,我的文件有:
Line1sometextBBBBBBB
我的外部 table 读取为:
Line1sometext
我也希望文件载入空白。我怎样才能阻止它删除尾随的白色space?
当前问题是:
如果文件有:
"this is a test value with
"
^ this new line is also a part of the row_data.
添加 a trim_spec
clause,特别是在此处 NOTRIM
,以更改默认字段修剪行为:
... FIELDS REJECT ROWS WITH ALL NULL FIELDS (ROW_DATA POSITION(1:4000) char NOTRIM)) LOCATION (...
^^^^^^
快速演示:
create table t42_ext (
row_data varchar2(4000)
)
organization external
(
type oracle_loader default directory mydir access parameters
(
records delimited by newline nobadfile nodiscardfile
fields reject rows with all null fields
(
row_data position(1:4000) char notrim
)
)
location ('temp.txt')
)
reject limit unlimited;
Table T42_EXT created.
select '<'|| row_data ||'>' from t42_ext;
'<'||ROW_DATA||'>'
--------------------------------------------------------------------------------
<Line1sometext >
我正在尝试将文件内容加载到外部 table。执行此操作时,尾随 space 会被截断。
'CREATE TABLE ' || rec.ext_table_name || ' (ROW_DATA VARCHAR2(4000)) ORGANIZATION EXTERNAL ' ||
'(TYPE ORACLE_LOADER DEFAULT DIRECTORY ' || rec.dir_name || ' ACCESS ' || 'PARAMETERS (RECORDS ' ||
'DELIMITED by NEWLINE NOBADFILE NODISCARDFILE ' ||
'FIELDS REJECT ROWS WITH ALL NULL FIELDS (ROW_DATA POSITION(1:4000) char)) LOCATION (' || l_quote ||
'temp.txt' || l_quote || ')) REJECT LIMIT UNLIMITED'
例如,B
表示空白 space,我的文件有:
Line1sometextBBBBBBB
我的外部 table 读取为:
Line1sometext
我也希望文件载入空白。我怎样才能阻止它删除尾随的白色space?
当前问题是:
如果文件有:
"this is a test value with
"
^ this new line is also a part of the row_data.
添加 a trim_spec
clause,特别是在此处 NOTRIM
,以更改默认字段修剪行为:
... FIELDS REJECT ROWS WITH ALL NULL FIELDS (ROW_DATA POSITION(1:4000) char NOTRIM)) LOCATION (...
^^^^^^
快速演示:
create table t42_ext (
row_data varchar2(4000)
)
organization external
(
type oracle_loader default directory mydir access parameters
(
records delimited by newline nobadfile nodiscardfile
fields reject rows with all null fields
(
row_data position(1:4000) char notrim
)
)
location ('temp.txt')
)
reject limit unlimited;
Table T42_EXT created.
select '<'|| row_data ||'>' from t42_ext;
'<'||ROW_DATA||'>'
--------------------------------------------------------------------------------
<Line1sometext >