一,、oracle10g提供ADDM的功能,,用em來(lái)看ADDM的報(bào)告自然非常容易,下面說(shuō)下如果用sql來(lái)獲得,,兩種方法:
1,、下面的sql可以得到最近一次的報(bào)告
SET LONG 1000000 PAGESIZE 0 LONGCHUNKSIZE 1000
COLUMN get_clob FORMAT a80
SELECT dbms_advisor.GET_TASK_REPORT(task_name)
FROM dba_advisor_tasks
WHERE task_id = (
SELECT max(t.task_id)
FROM dba_advisor_tasks t,
dba_advisor_log l
WHERE t.task_id = l.task_id AND
t.advisor_name = 'ADDM' AND
l.status = 'COMPLETED');
或者通過(guò)查詢(xún)SELECT * FROM dba_advisor_tasks;
得到需要時(shí)間點(diǎn)的task_name,然后單獨(dú)執(zhí)行
SET LONG 1000000 PAGESIZE 0 LONGCHUNKSIZE 1000
COLUMN get_clob FORMAT a80
SELECT dbms_advisor.get_task_report('SCOTT_ADDM', 'TEXT', 'TYPICAL|ALL')
FROM sys.dual;
就可以得到所需時(shí)間點(diǎn)的報(bào)告,。
2,、下面的腳本可以取得兩個(gè)快照之間的報(bào)告(有點(diǎn)類(lèi)似statspack):
SQL> @?/rdbms/admin/addmrpt
二、使用ADDM還可以自動(dòng)監(jiān)控?cái)?shù)據(jù)庫(kù)中表的增刪改的數(shù)量(類(lèi)似以前的alter table ... monitoring),,方法如下:
1,、啟用ADDM當(dāng)然statistics_level得是TYPICAL或ALL了
2、檢查一張新表test.test沒(méi)有被修改過(guò),,如果插入記錄:
SQL> select * from dba_tab_modifications where table_owner='TEST' and table_name='TEST';
no rows selected
SQL> INSERT INTO TEST.TEST VALUES (1,1,1);
1 row created.
SQL> COMMIT;
Commit complete.
3,、手工將sga的修改表信息push到數(shù)據(jù)字典中(不然要等15分鐘),然后查看數(shù)據(jù)字典里的情況:
SQL> exec dbms_stats.FLUSH_DATABASE_MONITORING_INFO();
PL/SQL procedure successfully completed.
SQL> select * from dba_tab_modifications where table_owner='TEST';
TABLE_OWNER TABLE_NAME
------------------------------ ------------------------------
PARTITION_NAME SUBPARTITION_NAME INSERTS
------------------------------ ------------------------------ ----------
UPDATES DELETES TIMESTAMP TRU DROP_SEGMENTS
---------- ---------- --------- --- -------------
TEST TEST
1
0 0 04-SEP-07 NO 0
可以看到inserts變?yōu)?了,。
4,、重新收集表的信息會(huì)怎么樣?
SQL> execute DBMS_STATS.GATHER_TABLE_STATS('TEST','TEST');
PL/SQL procedure successfully completed.
SQL> select * from dba_tab_modifications where table_owner='TEST' and
table_name='TEST';
no rows selected
呵呵,,沒(méi)有了,。這是因?yàn)橹匦陆y(tǒng)計(jì)后,oracle認(rèn)為那些信息是舊的了,,所以就沒(méi)了,,這點(diǎn)要注意。