开发者

Replace CHAR with VARCHAR2

开发者 https://www.devze.com 2022-12-23 02:32 出处:网络
How can I replace CHAR with VARCHAR2 in all tables in a schema? Note: I\'m content with a query that ret开发者_运维问答urns the ALTER TABLE statements so I can save the script and run it again.select

How can I replace CHAR with VARCHAR2 in all tables in a schema?

Note: I'm content with a query that ret开发者_运维问答urns the ALTER TABLE statements so I can save the script and run it again.


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
);
0

精彩评论

暂无评论...
验证码 换一张
取 消