3

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

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

4

1 回答 1

6
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
);
于 2010-03-15T09:15:03.747 回答