日期:2014-05-16 浏览次数:20531 次
CREATE OR REPLACE PROCEDURE PROC_CONVERTBYTETOCHAR IS v_strSQL varchar2(200); cursor cur_toChar is select table_name,column_name,data_type,data_length,data_default from user_tab_columns where char_used='B' and data_type='VARCHAR2'; rec_toChar cur_toChar%rowtype; BEGIN if cur_tochar%isopen then close cur_toChar; end if; open cur_toChar; loop fetch cur_tochar INTO rec_toChar; exit when cur_toChar%notfound; v_strSQL :=' alter table '||rec_toChar.Table_Name ||' modify '||rec_toChar.Column_Name ||' varchar2('||rec_toChar.Data_Length||' char) '; EXECUTE IMMEDIATE v_strSQL; commit; end loop; close cur_toChar; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(SQLERRM); END;
SELECT * FROM USER_TAB_COLUMNS WHERE CHAR_USED='B'