您好,登录后才能下订单哦!
1、指定待插入字符串类型为clob,可以使用过程或存储过程
例子:
DECLARE
REALLYBIGTEXTSTRING CLOB := '待插入的海量字符串';
BEGIN
INSERT INTO test_table VALUES('test', REALLYBIGTEXTSTRING, '0');
commit;
end ;
2、blob字段数据转换为clob类型
CREATE OR REPLACE FUNCTION blob_to_clob (blob_in IN BLOB) RETURN CLOB
AS
v_clob CLOB;
v_varchar VARCHAR2(32767);
v_start PLS_INTEGER := 1;
v_buffer PLS_INTEGER := 32767;
tmp_num number;
BEGIN
DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);
tmp_num := CEIL(DBMS_LOB.GETLENGTH(blob_in) / v_buffer);
if tmp_num > 0 then --防止传入的BLOB为NULL或长度为0时引发错误
FOR i IN 1..tmp_num
LOOP
v_varchar := UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(blob_in, v_buffer, v_start));
DBMS_LOB.WRITEAPPEND(v_clob, LENGTH(v_varchar), v_varchar);
v_start := v_start + v_buffer;
END LOOP;
end if;
RETURN v_clob;
END blob_to_clob;
2.调用blob_to_clob 来完成转换
update gs_gift p set p.description1=blob_to_clob(p.description);
commit;
3、sqlload 大字段(LOB类型)的导入
https://www.open-open.com/pdf/aab245f2dcdb421f9c98ec00e695b8a6.html
http://blog.itpub.net/31015730/viewspace-2147266
https://blog.csdn.net/u011364306/article/details/50598321(操作参考文章)
1)数据保存在独立的文件中
CREATE TABLE LOBTBL
(
FILEOWNER VARCHAR2(30),
FILENAME VARCHAR2(200),
FILESIZE NUMBER,
FILEDATA CLOB,
CREATE_DATE DATE
);
[oracle@cancer sqlldr]$ cat ldr_case12_2.dat
2016-1-27 15:21 183 oracle /home/oracle/sqlldr/ldr_case11_1.dat
2016-1-27 15:22 150 oracle /home/oracle/sqlldr/ldr_case11_1.ctl
2016-1-27 15:22 1,714 oracle /home/oracle/sqlldr/ldr_case11_1.log
2016-1-27 16:05 166 oracle /home/oracle/sqlldr/ldr_case11_2.ctl
2016-1-27 16:13 136 oracle /home/oracle/sqlldr/ldr_case11_2.bad
2016-1-27 16:13 204 oracle /home/oracle/sqlldr/ldr_case11_2.dat
2016-1-27 16:13 1,696 oracle /home/oracle/sqlldr/ldr_case11_2.log
2016-1-27 16:35 120 oracle /home/oracle/sqlldr/ldr_case11_3.ctl
2016-1-27 16:55 188 oracle /home/oracle/sqlldr/ldr_case11_3.dat
2016-1-27 16:55 1,695 oracle /home/oracle/sqlldr/ldr_case11_3.log
2016-1-27 20:15 183 oracle /home/oracle/sqlldr/ldr_case11_4.dat
2016-1-27 20:33 126 oracle /home/oracle/sqlldr/ldr_case11_4.ctl
2016-1-27 20:33 3 oracle /home/oracle/sqlldr/ldr_case11_4.bad
2016-1-27 20:33 1,829 oracle /home/oracle/sqlldr/ldr_case11_4.log
--控制文件
--控制文件
[oracle@cancer sqlldr]$ cat ldr_case12_2.ctl
LOAD DATA
INFILE ldr_case12_2.dat
TRUNCATE INTO TABLE LOBTBL
(
CREATE_DATE position(1:16) date 'yyyy-mm-dd hh34:mi',
FILESIZE position(*+2:23) "to_number(:FILESIZE,'99,999,999')",
FILEOWNER position(*+2:30),
FILENAME position(*+2:68) "substr(:FILENAME,instr(:FILENAME,'/',-1)+1)",
FILEDATA LOBFILE(FILENAME) TERMINATED BY EOF
执行sqlldr命令,并查看结果
--执行sqlldr命令
[oracle@cancer sqlldr]$ sqlldr scott/tiger control=ldr_case12_2.ctl
要加载的数据没有分隔符,而是固定长字符串时,可以在SQL*Loader的控制文件中通过position关键字用来指定列的开始和结束位置。position通常有下面3种写法:
【SQL*Loader】SQL*Loader实验之(5)--固定长字符串数据处理时position的3种写法
http://blog.itpub.net/20335819/viewspace-698052/
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。