So, we want to convert some columns from CLOB to VARCHAR2. Can I just do something like the following, or will some CLOB data get lost if I don't use something from DBMS_LOB, or something, to convert the data. As a critical note, the data in the CLOB column doesn't exceed 800 characters, and the VARCHAR2 we're creating holds 2000:
Code:
— add the "soon-to-be" DIRECTIONS column, naming it something novel
ALTER TABLE PUBEDUC.EDUDRECT
ADD (DIRECTIONS_NEW VARCHAR2(2000));
— move the data from the CLOB column into the VARCHAR2 column
UDPATE PUBEDUC.EDUDRECT
SET DIRECTIONS_NEW = DIRECTIONS;
— remove the CLOB column
ALTER TABLE PUBEDUC.EDUDRECT DROP COLUMN DIRECTIONS;
— rename the VARCHAR2 column back to the original field name
ALTER TABLE PUBEDUC.EDUDRECT
RENAME COLUMN DIRECTIONS_NEW TO DIRECTIONS;
---=cf