IT/db

oracle lob to long

generator 2010. 11. 17. 15:58
If you can't make head nor tail of it, try this one :

SQL> create table tbl_long (id number, text long);

Table created.

SQL> create table tbl_clob (id number, text clob);

Table created.

SQL> insert into tbl_clob select object_id, object_name from all_objects;

22074 rows created.

SQL> select * from tbl_clob where rownum<=5;

        ID TEXT

---------------------------------------------------------------- 18159 /1001a851_ConstantDefImpl 7781 /1005bd30_LnkdConstant 4841 /10076b23_OraCustomDatumClosur 17099 /10297c91_SAXAttrList 17712 /10322588_HandlerRegistryHelpe SQL> commit; Commit complete. SQL> SQL> declare 2 my_char varchar2(32000); 3 begin 4 for x in (select id, text from tbl_clob) loop 5 my_char := dbms_lob.substr(x.text, 32767, 1); 6 insert into tbl_long (id, text) values (x.id, my_char); 7 end loop; 8 end; 9 / PL/SQL procedure successfully completed. SQL> SQL> select * from tbl_long where rownum<=5;


http://forums.oracle.com/forums/thread.jspa?threadID=494181