How can I replace CHAR
with VARCHAR2
in all tables in a schema?
Note: I'm content with a query that returns the ALTER TABLE
statements so I can save the script and run it again.
From stackoverflow
-
select 'ALTER TABLE "' || owner || '"."' || table_name || '" MODIFY ("' || column_name || '" VARCHAR2(' || data_length || '));' from all_tab_columns 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 );
Aaron Digulla : I've extended the original answer to omit tables which are in the recycle bin. See http://stackoverflow.com/questions/2446053/what-are-the-bin-tables-in-oracles-all-tab-columns-table
0 comments:
Post a Comment