Oracle/Drop all user tables
Jump to navigation
Jump to search
-- 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 '||object_type||' '||object_name||';'
from USER_OBJECTS
--where object_type = 'TABLE'
order by object_type, object_name;
-- ... !!!
BEGIN
for c in (SELECT object_type, object_name FROM USER_OBJECTS) loop
execute immediate ('drop '||c.object_type||' '||c.object_name);
end loop;
END;
-- remove BIN$* objects
purge RECYCLEBIN;