字符串文字太长 - 如何将长 xml 数据分配给 oracle 11g r2 中的 clob 数据类型 [英] string literal too long - how to assign long xml data to clob data type in oracle 11g r2
问题描述
我需要将大约 30,000 行的非常大的 xml 数据分配给 oracle 数据库 11g r2 中的 CLOB 数据类型.我在 Oracle Sql Developer 中使用这个命令.
I need to assign a very large xml data of around 30,000 lines to a CLOB data type in oracle database 11g r2. I am using this command in Oracle Sql Developer.
当我使用以下命令时,首先我会收到 7 次 输入引用值
的提示,然后当语句执行完成时,我得到 - 'string literal too long` 错误.
When I use the following command, at first I get 7 prompts for entering quote value
and then when statement execution completes, I get - 'string literal too long` error.
update tablename set columnName = 'large xml data' where id=1;
我在 xml 数据中使用了七个双(单引号)来转义单引号.
I used seven double (single quotes) inside the xml data to escape the single quotes.
如何将这些数据分配到 CLOB 列?
How to assign this data to the CLOB column?
推荐答案
一种方法是使用 sqlldr.首先,创建一个小的保存表:
One approach is to use sqlldr. First, create a small holding table:
create table tstclob
(
id number,
doc clob
);
假设你的大文档是文件c:data est_doc.txt",创建一个sqlldr控制文件(test_doc.ctl")来加载它:
Assuming your large document is the file "c:data est_doc.txt", create a sqlldr control file ("test_doc.ctl") to load it:
load data
infile *
replace
into table tstclob
fields terminated by ','
(
ID char(1),
lob_file FILLER char,
DOC LOBFILE(lob_file) TERMINATED BY EOF
)
begindata
1,c:data est_doc.txt
然后运行 sqlldr(在本例中,从 c:data 目录):
Then run sqlldr (in this case, from c:data directory):
sqlldr control=test_doc.ctl userid=someuser@somedb/somepass
然后您可以使用 tstclob 表更新您想要的任何表.
You can then update whatever table you want using tstclob table.
这篇关于字符串文字太长 - 如何将长 xml 数据分配给 oracle 11g r2 中的 clob 数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!