Difference between revisions of "Oracle/Drop all user tables"
Jump to navigation
Jump to search
m |
|||
| Line 1: | Line 1: | ||
<source lang="oracle11"> | <source lang="oracle11"> | ||
-- v1 | |||
select 'drop table '||table_name||' cascade constraints;' from user_tables; | select 'drop table '||table_name||' cascade constraints;' from user_tables; | ||
-- v2 | |||
BEGIN | BEGIN | ||
for c in (select table_name from user_tables) loop | for c in (select table_name from user_tables) loop | ||
| Line 7: | Line 9: | ||
end loop; | end loop; | ||
END; | END; | ||
-- v3 (usable for other types too) | |||
select 'drop table '||object_name||' cascade constraints;' from USER_OBJECTS where object_type = 'TABLE'; | |||
</source> | </source> | ||
[[Category:Oracle]] | [[Category:Oracle]] | ||
Revision as of 08:55, 31 August 2010
-- v1
select 'drop table '||table_name||' cascade constraints;' from user_tables;
-- v2
BEGIN
for c in (select table_name from user_tables) loop
execute immediate ('drop table '||c.table_name||' cascade constraints');
end loop;
END;
-- v3 (usable for other types too)
select 'drop table '||object_name||' cascade constraints;' from USER_OBJECTS where object_type = 'TABLE';