oracle - 处理非常大的文本数据和 CLOB 列

标签 oracle oracle11g lob

根据 documentation CLOB 和 NCLOB 数据类型列,最多可以存储 8 TB 的字符数据。

我有包含 100 000 个字符的文本,如何运行这样的查询:

UPDATE my_table SET clob_column = 'text, which contains 100 000 characters' 
WHERE id = 1

?

如果在文本中,字符数高达 32767,则可以使用 PL/SQL 匿名块:
DECLARE
   myvar VARCHAR2(15000);
BEGIN
    myvar := 'text, which contains 100 000 characters';
    UPDATE my_table SET clob_column = myvar
    WHERE id = 1;
    ....
 END; 

什么是解决方案,其中文本非常大并且包含例如 100 000 个字符?

更新

我正在尝试 dbms_lob.append :
    create table t1 (c clob);

    declare
      c1 clob;
      c2 clob;
    begin
      c1 := 'abc';
      c2 := 'text, which contains 100 000 characters';
      dbms_lob.append(c1, c2);
      insert into t1 values (c1);
    end;

虽然,也有错误:string literal too long .

我做错了什么?

最佳答案

您应该使用 dbms_lob包,添加一些字符串到clob的过程是dbms_lob.append .

DBMS_LOB documentation

declare
  c1 clob;
  c2 varchar2(32000);
begin
  c1 := 'abc';
  c2 := 'text, which contains 32 000 characters';
  dbms_lob.append(c1, c2);
  c2 := 'some more text, which contains 32 000 characters';
  dbms_lob.append(c1, c2);
  insert into t1 values (c1);
end;

关于oracle - 处理非常大的文本数据和 CLOB 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20613348/

相关文章:

oracle - 与多行选择合并

sql - 在 Oracle SQL 中,如何转义列名中的连字符或按其位置提取列?

oracle - 如何查询几千个ID的列表

达到 Oracle XE 数据限制 - 如何减小表空间大小?

postgresql - 如何回收 PostgreSQL 中未使用的 LOB 占用的空间

java - 在 hibernate 中延迟加载一个 clob

sql - 返回一个 oracle 列作为时间戳

java - 如何在 Java 中修复 'SQLRecoverableException: Closed Connection'

oracle - 根据计数总和将记录拆分为存储桶

Oracle xmltype 列,创建 xmlindex 并包含以下路径