如何使用 SQL*Loader 截断数据以适合字段? (ORA-12899)

发布于 2024-09-07 06:21:02 字数 729 浏览 1 评论 0原文

使用 Oracle SQL*Loader,我尝试将另一个数据库中的可变长度字符串 (lob) 列加载到 Oracle 中的 varchar2(4000) 列中。我们的字符串远远超过 4000 个字符,但每个人都同意这些字符串可以而且应该在迁移中被截断(我们已经查看了超过 4000 个字符的数据,它没有意义)。为此,我在控制文件中以这种方式指定了列:

COMMENTS CHAR(65535) "SUBSTR(:COMMENTS, 1, 4000)",

但是,SQL*Loader 仍然拒绝数据文件中该记录长度超过 4000 个字符的任何行:

记录 6484:已拒绝 - 表 LOG_COMMENT、列 COMMENTS 出错。 ORA-12899: COMMENTS 列的值太大(实际:11477,最大值:4000)

记录 31994:已拒绝 - 表 LOG_COMMENT、列 COMMENTS 出错。 ORA-12899: COMMENTS 列的值太大(实际:16212,最大值:4000)

记录 44063:已拒绝 - 表 LOG_COMMENT、列 COMMENTS 出错。 ORA-12899: COMMENTS 列的值太大(实际:62433,最大值:4000)

我尝试采用更小的子字符串,但仍然遇到相同的错误。如何更改控制文件以将长度超过 4000 个字符的字符串数据截断到 varchar2(4000) 列中?

Using Oracle SQL*Loader, I am trying to load a column that was a variable length string (lob) in another database into a varchar2(4000) column in Oracle. We have strings much longer than 4000 characters, but everyone has agreed that these strings can and should be truncated in the migration (we've looked at the data that goes beyond 4000 characters, it's not meaningful). To do so, I specified the column this way in the control file:

COMMENTS CHAR(65535) "SUBSTR(:COMMENTS, 1, 4000)",

However, SQL*Loader still rejects any row where this record is longer than 4000 characters in the data file:

Record 6484: Rejected - Error on table LOG_COMMENT, column COMMENTS.
ORA-12899: value too large for column COMMENTS (actual: 11477, maximum: 4000)

Record 31994: Rejected - Error on table LOG_COMMENT, column COMMENTS.
ORA-12899: value too large for column COMMENTS (actual: 16212, maximum: 4000)

Record 44063: Rejected - Error on table LOG_COMMENT, column COMMENTS.
ORA-12899: value too large for column COMMENTS (actual: 62433, maximum: 4000)

I tried taking a much smaller substring and still got the same error. How can I change my control file to truncate string data longer than 4000 characters into a varchar2(4000) column?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花落人断肠 2024-09-14 06:21:02

检查以确保您的数据 ENCODING 和 Oracle ENCODING 不冲突。
在这种情况下,加载时使用 CHARACTERSET 选项。

Check to make sure your data ENCODING and Oracle ENCODING are not conflict.
In this case, use CHARACTERSET option when loading.

久而酒知 2024-09-14 06:21:02

无论如何,

COMMENTS CHAR(65535) "SUBSTR(:COMMENTS, 1, 4000)",

这是正确的语法。
使用 sqlldr 11.2.0.1 它对我来说可以成功工作,直到输入记录列 > 4000,

ORA-01461: can bind a LONG value only for insert into a LONG column

如果我切换到直接路径负载,我会得到 a,然后我会像你一样得到 smae 错误。

ORA-12899: value too large for column COMMENTS (actual: 4005, maximum: 4000)

最后我把它分成了 2 阶段加载..我现在有一个临时表,其中有一列 CLOB 类型的列,我加载该表,

COMMENTS CHAR(2000000000) 

然后将其插入到 eth 主表中,希望

insert into propertable
select dbms_lob.substr(comments,1,4000)
from staging_table;

这会有所帮助

by all accounts

COMMENTS CHAR(65535) "SUBSTR(:COMMENTS, 1, 4000)",

is the correct syntax.
using sqlldr 11.2.0.1 it works successfully for me up until the point where the input record column is > 4000 where i get a

ORA-01461: can bind a LONG value only for insert into a LONG column

if i switch to a directpath load then i get the smae error as you.

ORA-12899: value too large for column COMMENTS (actual: 4005, maximum: 4000)

in the end i have split it into a 2 stage load.. i now have a staging table with a column of type CLOB which i load with

COMMENTS CHAR(2000000000) 

which then gets inserted to eth main table with a

insert into propertable
select dbms_lob.substr(comments,1,4000)
from staging_table;

hope thats helpful

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文