1.查看自动收集统计信息的任务及状态
1 sys@ora11g> select client_name,status from dba_autotask_client; 2 3 CLIENT_NAME STATUS 4 ------------------------------------- -------- 5 auto optimizer stats collection ENABLED 6 auto space advisor ENABLED 7 tuning advisor ENABLED
其中“auto optimizer stats collection”便是我们要寻找的自动收集统计信息的任务名称,它的状态目前是启用状态。
2.禁止自动sql tuning advisor的任务
我们可以使用DBMS_AUTO_TASK_ADMIN包完成这个任务。
1 sys@ora11g> exec DBMS_AUTO_TASK_ADMIN.DISABLE(client_name => 'sql tuning advisor',operation => NULL,window_name => NULL); 2 3 PL/SQL procedure successfully completed. 4 5 sys@ora11g> select client_name,status from dba_autotask_client; 6 7 CLIENT_NAME STATUS 8 ------------------------------------- -------- 9 auto optimizer stats collection ENABLED 10 auto space advisor ENABLED 11 sql tuning advisor DISABLED
此时“sql tuning advisor”任务已经被禁用,目的达到。
3.启用sql tuning advisor的任务
1 sys@ora11g> exec DBMS_AUTO_TASK_ADMIN.ENABLE(client_name => 'sql tuning advisor',operation => NULL,window_name => NULL); 2 3 PL/SQL procedure successfully completed. 4 5 sys@ora11g> select client_name,status from dba_autotask_client; 6 7 CLIENT_NAME STATUS 8 ------------------------------------- -------- 9 auto optimizer stats collection ENABLED 10 auto space advisor ENABLED 11 sql tuning advisor ENABLED