Saturday, August 30, 2008

Convert all column from BYTE to CHARACTER

SET SERVEROUT ON
SPOOL CONV_B2C.SQL
BEGIN
EXECUTE IMMEDIATE 'PURGE RECYCLEBIN';
FOR X IN(SELECT table_name,column_name,data_length FROM COLS WHERE DATA_TYPE='VARCHAR2' AND CHAR_USED='B')
LOOP
DBMS_OUTPUT.PUT_LINE('ALTER TABLE '||X.TABLE_NAME||' MODIFY '||X.COLUMN_NAME||' VARCHAR2('||X.DATA_LENGTH||' CHAR);');
END LOOP;
END;
/
SPOOL OFF;


then run the script,
SQL>@CONV_B2C.SQL

No comments:

search engine

Custom Search