declare cursor c_obj is select T.OBJECT_TYPE,T.OBJECT_NAME from user_objects t ; v_sql varchar2(100); begin for c_obj_i in c_obj loop if c_obj_i.object_type not in('INDEX','LOB') then begin v_sql :='drop '||c_obj_i.object_type||' ' ||c_obj_i.object_name; if c_obj_i.object_type='TABLE' then v_sql :=v_sql||' CASCADE CONSTRAINTS PURGE'; end if; execute immediate v_sql; exception when others then dbms_output.put_line(v_sql||' ---'||sqlerrm); end; end if; end loop; end;
删除某一用户下除去lob、index 所有的东西 ORACLE
最新推荐文章于 2021-04-15 03:29:05 发布
本文提供了一段PL/SQL代码,用于批量删除Oracle数据库中的非索引和非LOB类型的用户对象,如视图、序列和表等。代码通过游标遍历USER_OBJECTS视图,并使用动态SQL执行DROP命令。对于表对象,还会级联删除约束并清除数据。

656

被折叠的 条评论
为什么被折叠?



