Search code examples
oracleoracle11goracle-aq

How to purge an Advanced Queue in Oracle


The documentation is clear about how to purge an Oracle AQ:

dbms_aqadm.purge_queue_table()

However, what happens to the storage, especially the high water marks of the queue table, the indexes and of the LOB segments? Is it necessary to shrink the table, too?

In production, the queues are nearly always empty (as they should), but in our test system, they fill up to millions of rows for various reasons, so they need to be emptied sometimes.

Is it neccessary to look at the underlying tables and indexes or is this taken care of automatically?

Many thanks!


Solution

  • DBMS_AQADM.PURGE_QUEUE_TABLE it is equivalent for truncate table. Also look at this error message when you try truncate queue table

    ORA-24005: Inappropriate utilities used to perform DDL on AQ table %s.%s
     *Cause:  An attempt was made to use the SQL command DROP TABLE or TRUNCATE
              TABLE or ALTER TABLE on queue metadata or tables.
     *Action: Use the DBMS_AQADM.DROP_QUEUE_TABLE to DROP TABLE,
              DBMS_AQADM.PURGE_QUEUE_TABLE to TRUNCATE TABLE.
              ALTER TABLE redefinition based on only ALTER_TABLE_PROPERTIES and
              ALTER_TABLE_PARTITIONING clauses are allowed.
    

    Tom Kyte has already written info about often truncating table https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:47911859692542