删除触发器后无法删除的回收站对象

时间:2018-12-21 22:41:20

标签: oracle plsql oracle12c

我正在使用Oracle版本12c。我创建了一个触发器,该触发器应该创建一个审计条目,因此将其称为before update(我简化了以下示例以使其易于阅读-错误保持不变)。我正在对clean db使用ant目标(整个recreate目标的第一步)。 clean db步骤如下:

BEGIN
    FOR c IN (SELECT object_name FROM user_procedures) LOOP
        EXECUTE IMMEDIATE ('DROP PROCEDURE "' || c.object_name || '"');
    END LOOP;
END;
/

user_tablesuser_views还有两个循环(为简洁起见,呼叫顺序为user_tables,然后依次为user_viewsuser_procedures)。当我将触发器放入迁移脚本中时(我正在使用flyway):

CREATE OR REPLACE TRIGGER trg_car_audit
    BEFORE UPDATE
    ON CAR
    FOR EACH ROW
BEGIN
    INSERT INTO CAR (ID, MANUFACTURER, MODEL)
    VALUES (:OLD.ID, :OLD.MANUFACTURER, :OLD.MODEL);
END;
/

在整个recreate db蚂蚁目标中,它到达了clean db目标中的点,我得到:

Failed to execute:  BEGIN FOR c IN (SELECT object_name FROM user_procedures) LOOP EXECUTE IMMEDIATE ('DROP PROCEDURE "' || c.object_name || '"'); END LOOP; END; 
java.sql.SQLSyntaxErrorException: ORA-04043: object BIN$fZDGeHfvC9bhUiQJFawHpg==$0 doesn't exist

当我执行:SELECT * FROM user_procedures时,它会给我:

OBJECT_NAME                     PROCEDURE_NAME OBJECT_ID SUBPROGRAM_ID OVERLOAD  OBJECT_TYPE  AGGREGATE  PIPELINED  IMPLTYPEOWNER IMPLTYPENAME PARALLEL INTERFACE  DETERMINISTIC AUTHID   ORIGIN_CON_ID
------------------------------- -------------- --------- ------------- --------- ------------ ---------- ---------- ------------- ------------ -------- ---------- ------------- -------  -------------
BIN$fZDGeHfvC9bhUiQJFawHpg==$0  NULL           120236    1             NULL      TRIGGER      NO         NO         NULL          NULL         NO       NO         NO            DEFINER  0

我只能通过purge recyclebin;摆脱它。


  1. bin*项放入 user_procedures表?
  2. 有办法解决吗?怎么样?

我拥有DROP ANY PROCEDURE系统特权(我确实有其他过程,可以被完全丢弃)

1 个答案:

答案 0 :(得分:4)

您的过程尝试删除已删除的内容。您可以识别出来,因为其名称以“ BIN $”开头。清除后,问题消失了。

解决方案是过滤不以'BIN $'开头的object_name

BEGIN
    FOR c IN (SELECT object_name FROM user_procedures
              WHERE object_name NOT LIKE 'BIN$%' ) LOOP
        EXECUTE IMMEDIATE ('DROP PROCEDURE "' || c.object_name || '"');
    END LOOP;
END;
/