EBS 11i & DB 11gR2--PURGE ASO_ORDER_FEEDBACK_T

前陣子顧問通知我們,我們EBS 11i上有一個9G的Table:ASO_ORDER_FEEDBACK_T, 雖然沒有相關模組在使用,但是也是會增長,所以建議停用且刪除資料。

先依文件ID 1432251.1檢查是否有被使用
(How To Determine If Trade Management Is Used Before Truncating ASO_ORDER_FEEDBACK_T)

SQL> select count(1) from ozf_funds_utilized_all_b;
SQL> select count(1) from ozf_funds_all_b;
SQL> select count(1) from ozf_act_budgets;

上面的結果回傳都是0,表示我們曾未執行過Funds Accrual Engine,也沒有使用Trade Management Budgets模組

接著到ERP去停用它,以免未來它又不斷地增長
需要用到Responsibility:Quoting Sales Manager


Quoting Sales Manager-> Quick Codes
尋找Type是ASO_ORDER_FEEDBACK_CRM_APPS,並且取消OZF的Enabled勾選,也可以直接刪除OZF,如下圖



接著刪除ASO.ASO_ORDER_FEEDBACK_T的資料,文件(ID 603427.1)提到要truncate四個table
truncate table ASO.ASO_ORDER_FEEDBACK_T REUSE STORAGE;
truncate table ASO.AQ$_ASO_ORDER_FEEDBACK_T_I REUSE STORAGE;
truncate table ASO.AQ$_ASO_ORDER_FEEDBACK_T_H REUSE STORAGE;
truncate table ASO.AQ$_ASO_ORDER_FEEDBACK_T_T REUSE STORAGE;

由於我們的DB是11gR2,已經不建議用上面的方式來刪除AQ objects,所以出現了ora-24005的錯誤訊息
SQL> truncate table ASO.ASO_ORDER_FEEDBACK_T;
truncate table ASO.ASO_ORDER_FEEDBACK_T
                   *
ERROR at line 1:
ORA-24005: Inappropriate utilities used to perform DDL on AQ table
ASO.ASO_ORDER_FEEDBACK_T

改用DBMS_AQADM的Package來刪除ASO.ASO_ORDER_FEEDBACK_T,程式如下:
declare
  po dbms_aqadm.aq$_purge_options_t;
begin
  po.block := FALSE;
  dbms_aqadm.purge_queue_table_table(
      queue_table => 'ASO.ASO_ORDER_FEEDBACK_T',
       purge_condition => null,
       purge_options => po );
end ;
/

查詢一下dba_objects,發現不是只有ASO_ORDER_FEEDBACK_T有改變
SQL> select owner,
            object_name,
            to_char(last_ddl_time,'yyyy/mm/dd hh24:mi') last_ddl_time
       from dba_objects
       where last_ddl_time >= to_date('20140515','yyyymmdd')
         and object_name like '%ASO_ORDER_FEEDBACK%';

          OWNER      OBJECT_NAME                    LAST_DDL_TIME
---------- ------------------------------ --------------------------------
ASO        AQ$_ASO_ORDER_FEEDBACK_T_H     2014/05/15 16:37
ASO        AQ$_ASO_ORDER_FEEDBACK_T_I     2014/05/15 16:37
ASO        AQ$_ASO_ORDER_FEEDBACK_T_T     2014/05/15 16:37
ASO        ASO_ORDER_FEEDBACK_T                   2014/05/15 16:37

查詢ASO_ORDER_FEEDBACK_T的大小,發現只剩下0.13MB
SQL> select segment_name,segment_type,round(sum(bytes)/1024/1024,2) "MB" ,sum(blocks) "BLOCKS"
        from dba_segments
        where segment_name = 'ASO_ORDER_FEEDBACK_T'                                          
        group by  segment_name,segment_type ;

SEGMENT_NAME                   SEGMENT_TY         MB     BLOCKS
------------------------------ ---------- ---------- ----------
ASO_ORDER_FEEDBACK_T           TABLE             .13         16


我只有執行到這裡,ID 603427.1提到有四個步驟要做,如下:

Step 1 : Truncate the table
sqlplus "/as sysdba"
SQL> truncate table ASO.ASO_ORDER_FEEDBACK_T REUSE STORAGE;
SQL> truncate table ASO.AQ$_ASO_ORDER_FEEDBACK_T_I REUSE STORAGE;
SQL> truncate table ASO.AQ$_ASO_ORDER_FEEDBACK_T_H REUSE STORAGE;
SQL> truncate table ASO.AQ$_ASO_ORDER_FEEDBACK_T_T REUSE STORAGE;
SQL> COMMIT;


Step 2 : Grant execute rights on SYS.DBMS_AQADM and SYS.DBMS_AQ packages with Grant options to users APPS & ASO
grant execute on SYS.DBMS_AQADM to ASO WITH GRANT OPTION;
grant execute on SYS.DBMS_AQADM to APPS WITH GRANT OPTION;
grant execute on SYS.DBMS_AQ to ASO WITH GRANT OPTION;
grant execute on SYS.DBMS_AQ to APPS WITH GRANT OPTION;


Step 3:  Run asoqueue.sql script.
$ cd $ASO_TOP/patch/115/sql


Step 4: When previous steps are completed, then run :-
ALTER TABLE ASO.ASO_ORDER_FEEDBACK_T DEALLOCATE UNUSED;
ALTER TABLE ASO.AQ$_ASO_ORDER_FEEDBACK_T_I DEALLOCATE UNUSED;
ALTER TABLE ASO.AQ$_ASO_ORDER_FEEDBACK_T_H DEALLOCATE UNUSED;
ALTER TABLE ASO.AQ$_ASO_ORDER_FEEDBACK_T_T DEALLOCATE UNUSED;