如何清除statspack相關表的歷史資料

2021-07-24 03:21:47 字數 3450 閱讀 5553

本次想清除2023年以前statspack相關表的歷史資料。

1.找出2023年1月1日之前對應最大的snap_id值

2.根據oracle db環境的官方提供的指令碼($oracle_home/rdbms/admin/sptrunc.sql)

declare

l_snap_id number := 103;

begin

delete from stats$filestatxs where snap_id <= l_snap_id;

delete from stats$tempstatxs where snap_id <= l_snap_id;

delete from stats$latch where snap_id <= l_snap_id;

delete from stats$latch_children where snap_id <= l_snap_id;

delete from stats$latch_misses_summary where snap_id <= l_snap_id;

delete from stats$latch_parent where snap_id <= l_snap_id;

delete from stats$librarycache where snap_id <= l_snap_id;

delete from stats$buffer_pool_statistics where snap_id <= l_snap_id;

delete from stats$rollstat where snap_id <= l_snap_id;

delete from stats$rowcache_summary where snap_id <= l_snap_id;

delete from stats$sga where snap_id <= l_snap_id;

delete from stats$sgastat where snap_id <= l_snap_id;

delete from stats$sysstat where snap_id <= l_snap_id;

delete from stats$sesstat where snap_id <= l_snap_id;

delete from stats$system_event where snap_id <= l_snap_id;

delete from stats$session_event where snap_id <= l_snap_id;

delete from stats$bg_event_summary where snap_id <= l_snap_id;

delete from stats$waitstat where snap_id <= l_snap_id;

delete from stats$enqueue_stat where snap_id <= l_snap_id;

delete from stats$sql_summary where snap_id <= l_snap_id;

delete from stats$sql_statistics where snap_id <= l_snap_id;

delete from stats$sqltext where last_snap_id <= l_snap_id;

delete from stats$parameter where snap_id <= l_snap_id;

delete from stats$resource_limit where snap_id <= l_snap_id;

delete from stats$dlm_misc where snap_id <= l_snap_id;

delete from stats$undostat where snap_id <= l_snap_id;

delete from stats$sql_plan where snap_id <= l_snap_id;

delete from stats$sql_plan_usage where snap_id <= l_snap_id;

delete from stats$seg_stat where snap_id <= l_snap_id;

--select * from stats$seg_stat_obj

delete from stats$db_cache_advice where snap_id <= l_snap_id;

delete from stats$pgastat where snap_id <= l_snap_id;

delete from stats$instance_recovery where snap_id <= l_snap_id;

delete from stats$snapshot where snap_id <= l_snap_id;

delete from stats$database_instance where snap_id <= l_snap_id;

commit;

exception

when others then

rollback;

end;

由於採用以上方法刪除資料非常慢,通常是刪除全部統計的歷史記錄。建議用oracle db使用者perfstat操作,具體方法如下:

sql> @$oracle_home/rdbms/admin/sptrunc.sql

warning

~~~~~~~

running sptrunc.sql removes all data from statspack tables. you may

wish to export the data before continuing.

about to truncate statspack tables

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if would like to exit without truncating the tables, enter any text at the

begin_or_exit prompt (e.g. 'exit'), otherwise if you would like to begin

the truncate operation, press enter value for begin_or_exit:

在「enter value for begin_or_exit: 」處無需求輸入,直接回車就即可。

如何清除浮動

1 使用overflow 屬性 給浮動元素的容器新增overflow hidden 或overflow auto 可以清除浮動,另外在 ie6 中還需要觸發 haslayout 例如為父元素設定容器寬高或設定 zoom 1。father2 給浮動元素的容器新增浮動 給浮動元素的容器也新增上浮動屬性即...

如何清除tomcat快取

用tomcat容器,大家可能會發現這樣的問題,修改jsp檔案後,但用ie開啟 依然是以前的jsp的頁面。出現這種現象的原因主要是tomcat快取的原因。解決辦法如下 在jsp檔案頭加上 其中,第一行的content 0 是表示過期的時間,如果不是0的話,就必須使用gmt的時間格式。第二行表示不用快取...

4199病毒如何清除

xiaodaoxiaodao 藍小刀http blog.csdn.net xiaodaoxiaodao archive 2006 09 24 1271275.aspx 作者 4199病毒如何清除 最近電腦中了病毒,特徵是首頁被修改為http www.4199.com,上網查了一下,是這兩天流行的41...