Hi, here's one way to do it:
1. Create a table similar to the original but replace the LONG datatype by a VARCHAR2 datatype.
2. Verify that the LONG column data doesn't exceed 4000 bytes.
3. Create an anonymous pl/sql block similar to the one below, and execute it.
TABLES:
SQL> desc test_1
Name Null? Type
------------------------------- -------- ----
COL_1 NUMBER
COL_2 LONG
SQL> desc test_2
Name Null? Type
------------------------------- -------- ----
COL_1 NUMBER
COL_2 VARCHAR2(4000)
PL/SQL Block:
declare
string varchar2(4000);
v_id number;
cursor c_test_1
is
select col_1, col_2
from test_1;
begin
for r_test_1 in c_test_1 loop
insert into test_2 values (r_test_1.col_1, r_test_1.col_2);
end loop;
commit;
end;
/
4. remove the original table and rename the new one to the name of the original table. Verify that all triggers and constraints are set properly.
HTH,
MHE