OTA*_*TAR 5 oracle lob oracle11g
根据 文档 CLOB和NCLOB数据类型列,可以存储多达8 TB的字符数据.
我有文本,其中包含10万个字符,如何运行这样的查询:
UPDATE my_table SET clob_column = 'text, which contains 100 000 characters'
WHERE id = 1
Run Code Online (Sandbox Code Playgroud)
?
如果在文本中,字符数最多为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;
Run Code Online (Sandbox Code Playgroud)
什么是解决方案,其中文本非常大并且包含例如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;
Run Code Online (Sandbox Code Playgroud)
虽然,也有错误:string literal too long.
我做错了什么?
你应该使用dbms_lob包,将一些字符串添加到clob的过程是dbms_lob.append.
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;
Run Code Online (Sandbox Code Playgroud)