oracle sql - remove a user's all objects

Posted 无处安放的灵魂

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle sql - remove a user's all objects相关的知识,希望对你有一定的参考价值。

DECLARE

TYPE cst_table_list IS TABLE OF VARCHAR2(40); TYPE cst_list IS TABLE OF VARCHAR2(40);

TYPE name_list IS TABLE OF VARCHAR2(40); TYPE type_list IS TABLE OF VARCHAR2(20);

cst_tab_name cst_table_list:=cst_table_list(); cst_name cst_list:=cst_list();

Tab_name name_list:=name_list(); Tab_type type_list:=type_list();

sql_str VARCHAR2(500);

v_err_code NUMBER; v_err_msg VARCHAR2(200);

BEGIN     -- drop all reference constraints begin     sql_str := ‘select table_name,constraint_name from user_constraints where constraint_type=‘‘R‘‘‘;     EXECUTE IMMEDIATE sql_str BULK COLLECT INTO cst_tab_name,cst_name;     FOR i IN cst_tab_name.FIRST.. cst_tab_name.LAST LOOP

        begin         sql_str := ‘ALTER TABLE ‘ || cst_tab_name(i) || ‘ DROP CONSTRAINT ‘ || cst_name(i);         EXECUTE IMMEDIATE sql_str;         dbms_output.put_line(sql_str);

        exception         when others then             v_err_code := SQLCODE;             v_err_msg := SUBSTR(SQLERRM, 1, 200);             DBMS_OUTPUT.PUT_LINE (‘Error code: ‘||v_err_code);             DBMS_OUTPUT.PUT_LINE (‘Error message: ‘||v_err_msg);

        end;

    END LOOP;

    -- drop all reference constraints end

    -- drop all tables, sequences...  begin     sql_str := ‘select uo.object_name,uo.object_type     from user_objects uo     where uo.object_type not in(‘‘INDEX‘‘,‘‘LOB‘‘)     order by uo.object_type desc‘;     EXECUTE IMMEDIATE sql_str BULK COLLECT INTO tab_name,tab_type;

    FOR i IN Tab_name.FIRST.. Tab_name.LAST LOOP         begin             sql_str := ‘DROP ‘ || Tab_type(i) || ‘ ‘ || Tab_name(i);             EXECUTE IMMEDIATE sql_str;             dbms_output.put_line(sql_str);

        exception             when others then                 v_err_code := SQLCODE;                 v_err_msg := SUBSTR(SQLERRM, 1, 200);                 DBMS_OUTPUT.PUT_LINE (‘Error code: ‘||v_err_code);                 DBMS_OUTPUT.PUT_LINE (‘Error message: ‘||v_err_msg);         end;

    END LOOP;     -- drop all tables, sequences...  end END;

以上是关于oracle sql - remove a user's all objects的主要内容,如果未能解决你的问题,请参考以下文章

PL/SQL Developer登录出现——Using a filter for all users can lead to poor performance!

Bullet:ORACLE Using SQL Plan Management

oracle日常监控语句

Oracle ---- 窗口函数

optimizer_use_sql_plan_baselines 和 resource_manager_cpu_allocation oracle系统参数是不是对sql查询性能有影响

Oracle报错ORA-01722: 无效数字排查解决方案