国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

oracle定時分析用戶下的所有表

瀏覽:43日期:2023-11-23 18:51:50

定時分析用戶下的所有表

你的數據庫運行在CBO的模式下,就要對你的表經常做分析,尤其是變化很大的表,這樣oracle才會選擇正確的執行計劃,下面是我寫的一個按時分析表的一個的腳本

操作步驟:

1. 編寫執行分析表的procedure2. 編寫調用procedure的os的shell腳本3. 在os做crontab的定時任務

1. 編寫執行分析表的procedure

create or replace procedure pro_analyze_user_objects (tablename varchar2; ---不分析的表名或表名的部分字符)is /******************************************************* author:skate time; :2009/04/16 功能:分析大于1000行的表的統計信息 說明:可以統計用戶下的所有大于1000行的表,如果要統計其他用戶 ,只要把這個procedure放在相應的用戶下或者用all_tables

eg:exec pro_analyze_user_objects('_his') 相關分析語句如下: analyze table D_COURSE compute statistics; for all indexes for all columns for table; analyze table D_COURSE compute statistics; ********************************************************/

cursor cur_tab isselect table_namefrom user_tables where num_rows>1000and table_name not like '%'||upper(tablename)||'%';record_cur_tab cur_tab%rowtype;

begin

open cur_tab;loopfetch cur_tab into record_cur_tab;exit when cur_tab%notfound;execute immediate 'analyze table '|| record_cur_tab.table_name || ' compute statistics';end loop;end pro_analyze_user_objects;

2. 編寫調用procedure的os的shell腳本

[oracle@svr-db-test sh]$ more ticket_analyze.sh#####################################author:skate#time; :2009/04/16#desc; : The timming analyze user of tables####################################

cd /home/oracle/shdatesqlplus /nolog @ ticket_analyze.sqldateexit[oracle@svr-db-test sh]$

[oracle@svr-db-test sh]$ more ticket_analyze.sqlconnect tickets/123456set timing onexec pro_analyze_user_objects('_his');exit;

[oracle@svr-db-test sh]$

¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥

3. 在os做crontab的定時任務

#ayalyze tickets all tables

1 07 * * * sh /home/oracle/sh/ticket_analyze.sh >> /home/oracle/sh/ticket_analyze.log

這樣一個每天7:01的定時分析表的任務就做完!!!

收工!!

標簽: Oracle 數據庫
主站蜘蛛池模板: 全椒县| 安西县| 浙江省| 黑河市| 蒙阴县| 那坡县| 宝清县| 化州市| 成安县| 吉林市| 连州市| 望江县| 文登市| 双峰县| 巴南区| 孝昌县| 浏阳市| 桐乡市| 健康| 孝昌县| 乌拉特后旗| 泸定县| 文登市| 夹江县| 肥城市| 应城市| 丰宁| 杭锦旗| 合肥市| 晋江市| 嵊州市| 清水河县| 衡阳市| 襄垣县| 屯门区| 雷波县| 克什克腾旗| 尉犁县| 张北县| 新兴县| 日喀则市|