如何清除 Oracle AQ 中的队列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4261891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:55:41  来源:igfitidea点击:

How to clear a queue in Oracle AQ

oraclequeuejmsoracle-aq

提问by jeph perro

I've been testing Oracle AQ for the first time. I have managed to create 2000 rows of test inserts into the queue I created.

我是第一次测试 Oracle AQ。我设法在我创建的队列中创建了 2000 行测试插入。

Now, I'd like to clear those out. As I was teaching myself, I set the expiry time to be a month. I can't wait that long. And I don't think I should just delete them from the queue table.

现在,我想清除这些。当我自学时,我将到期时间设置为一个月。我等不了那么久了。而且我认为我不应该只是从队列表中删除它们。

What's the best way to do this?

做到这一点的最佳方法是什么?

回答by erbsock

You can use the DBMS_aqadm.purge_queue_tableprocedure.

您可以使用该DBMS_aqadm.purge_queue_table程序。



SOLUTION

解决方案

The SQL looks something like this :

SQL 看起来像这样:

-- purge queue
DECLARE
 po_t dbms_aqadm.aq$_purge_options_t;
BEGIN
  dbms_aqadm.purge_queue_table('MY_QUEUE_TABLE', NULL, po_t);
END;

回答by JOTN

Just do a delete on the queue table.

只需对队列表进行删除。

Never mind, just did a check and that's not right:

没关系,只是做了一个检查,这是不对的

Oracle Streams AQ does not support data manipulation language (DML) operations on queue tables or associated index-organized tables (IOTs), if any. The only supported means of modifying queue tables is through the supplied APIs. Queue tables and IOTs can become inconsistent and therefore effectively ruined, if DML operations are performed on them.

Oracle Streams AQ 不支持对队列表或关联的索引组织表 (IOT)(如果有)进行数据操作语言 (DML) 操作。唯一支持的修改队列表的方法是通过提供的 API。如果对它们执行 DML 操作,队列表和 IOT 可能会变得不一致并因此被有效破坏。



So, you'll have to create a little PL/SQL routine to pull the items off.

因此,您必须创建一个小的 PL/SQL 例程来提取项目。

Use the dbms_aqpackage. Check the example from the documentation: Dequeuing Messages. Scroll down a little bit and there's a complete example.

使用dbms_aq包。检查文档中的示例:Dequeuing Messages。向下滚动一点,有一个完整的例子。