如何在架构中的所有表中将CHAR替换为VARCHAR2

注意:我对返回ALTER TABLE语句的查询感到满意,因此我可以保存脚本并再次运行它。

最佳答案

select 'ALTER TABLE "' || owner || '"."' || table_name
|| '" MODIFY ("' || column_name
|| '" VARCHAR2(' || data_length || '));'
from all_tab_columns tc
where data_type = 'CHAR'
and owner = :schemaname
and exists (
    select 1
    from all_tables t
    where tc.owner = t.owner
    and tc.table_name = t.table_name
);

关于oracle - 将CHAR替换为VARCHAR2,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2445982/

10-10 14:50