操作LONG型別

likesky276發表於2007-03-14

ORACLE已經不推薦用LONG型別了,改為CLOB,對於LONG操作有些限制,比如對於有LONG型別是不能用insert into xxxx select * from xxxx。

SQL> desc test1;
Name Type Nullable Default Comments
---- ------------ -------- ------- --------
A VARCHAR2(10) Y
B LONG Y

SQL> desc test2;
Name Type Nullable Default Comments
---- ------------ -------- ------- --------
A VARCHAR2(10) Y
B LONG Y

CREATE OR REPLACE PROCEDURE test3
IS
CURSOR c1 IS SELECT a,b FROM test1;
BEGIN
FOR r1 IN c1 LOOP
INSERT INTO test2 (a,b) VALUES(r1.a,r1.b);
END LOOP;
COMMIT;
END;

SQL> execute test3;

PL/SQL procedure successfully completed

在9i以後,可以直接將LONG轉為CLOB型別

SQL> alter table test1 modify b clob;

Table altered

SQL> alter table test2 modify b clob;

Table altered

SQL> insert into test2 select * from test1;

1 row inserted

SQL> commit;


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8118583/viewspace-64856/,如需轉載,請註明出處,否則將追究法律責任。

相關文章