Oracle CLOB 不能插入超过 4000 个字符?

Oracle CLOB can#39;t insert beyond 4000 characters?(Oracle CLOB 不能插入超过 4000 个字符?)
本文介绍了Oracle CLOB 不能插入超过 4000 个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将超过 4000 个字符插入 CLOB 类型的列?

How do I insert more than 4000 characters to a CLOB type column?

--create test table s
create table s
(
      a clob
);
insert into s values('>4000 char')

导致错误:

ORA-01704:字符串太长.

ORA-01704:the string too long.

我想一次性插入一个超过 4000 个字符的字符串.我该怎么做?有可能吗?

I want to insert a string of >4000 characters one time. How do I do it? Is it possible?

当我阅读 Oracle 参考资料时,CLOB 最多可以节省 4GB(Gigabyte)?

When I read the Oracle reference, CLOB can save max 4GB(Gigabyte)?

推荐答案

一次插入最多4000个字符(Oracle中最大的字符串字面量).但是,您可以使用 lob 函数 dbms_lob.append() 将(最多)4000 个字符的块附加到 clob:

The maximum for one time insertion is 4000 characters (the maximum string literal in Oracle). However you can use the lob function dbms_lob.append() to append chunks of (maximum) 4000 characters to the clob:

CREATE TABLE don (x clob);


DECLARE 
 l_clob clob;
BEGIN
  FOR i IN 1..10
  LOOP
    INSERT INTO don (x) VALUES (empty_clob()) --Insert an "empty clob" (not insert null)
    RETURNING x INTO l_clob;

    -- Now we can append content to clob (create a 400,000 bytes clob)
    FOR i IN 1..100
    LOOP
      dbms_lob.append(l_clob, rpad ('*',4000,'*'));
      --dbms_lob.append(l_clob, 'string chunk to be inserted (maximum 4000 characters at a time)');
    END LOOP;
  END LOOP;
END;

这篇关于Oracle CLOB 不能插入超过 4000 个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
Inserting NaN value into MySQL Database(将NaN值插入MySQL数据库)
How to get insertId for MySQL using Mysql2 in Node with async and pool?(如何在带异步和池的Node中使用Mysql2获取MySQL的InsertID?)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)