Oracle 批量修改字段长度
Oracle 批量修改字段长度
SELECT 'alter table '||a.table_name||' MODIFY '||A.COLUMN_NAME||' VARCHAR2(100);'
, A.table_name,A.COLUMN_NAME,A.DATA_TYPE,A.DATA_LENGTH,A.*
from user_tab_columns A
WHERE A.COLUMN_NAME='CREATE_USER' AND a.DATA_LENGTH<=20;
DECLARE
CURSOR CUR IS
SELECT * FROM USER_TAB_COLUMNS WHERE COLUMN_NAME='CREATE_USER';
STR VARCHAR2(8000):='';
BEGIN
FOR COL IN CUR LOOP
STR:=' ALTER TABLE '||COL.TABLE_NAME||' MODIFY '||COL.COLUMN_NAME||' VARCHAR2(100) ;';
DBMS_OUTPUT.PUT_LINE(STR);
END LOOP;
END;