暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

一键确认用户下的对象是否缺少统计信息

数据库驾驶舱 2024-08-26
68

登录需要确认的用户

SET ECHO off 
REM NAME: tfstbsta.sql 
REM USAGE:"@tfstbsta" 
REM ------------------------------------------------------------------------ 
REM REQUIREMENTS: 
REM    None. 
REM ------------------------------------------------------------------------ 
REM PURPOSE: 
REM    Shows all tables and indexes in the current schema which have  
REM    not had statistics computed. 
REM ------------------------------------------------------------------------ 
REM Main text of script follows: 
 
SET ECHO OFF 
col tn format a30 heading 'Table Name' 
col dn format a30 heading 'Index Name' 
col withstats format a10  heading 'Statistics' 
spool tfstbsta.lst 
set newpage 0 
ttitle CENTER 'List of all Optimizer Statistics' - 
 right 'Page:' format 999 sql.pno skip skip 
start time1 
set feedback on 
Prompt 
Prompt List of Tables  
Prompt 
select table_name  tn, 
       decode(blocks,null,'No','Yes') withstats 
from user_tables 

set embedded off 
Prompt 
Prompt List of Indexes  
Prompt 
select TABLE_NAME tn,  
       INDEX_NAME dn, 
       decode(BLEVEL,null,'No','Yes') withstats 
from user_indexes 

prompt 
prompt End of Report 
spool off 
set embedded off 
clear breaks 
clear computes 
clear columns 
set feedback 6 
set verify on  

Sample Output:

 
         List of all Optimzser Statistics           Page:  1  
 
List of Tables 
 
Table Name                     Statistics 
------------------------------ ---------- 
CUSTOMER                        No 
DEPT                            No  
EMP                             Yes 
IMAGE                           No 
  
 
List of Indexes 
 
         List of all Optimzser Statistics           Page:  1  
 
Table Name           Index Name                     Statistics 
-------------------- ------------------------------ ---------- 
CUSTOMER             CUSTOMER_ID_PK                 No  
DEPT                 DEPT_ID_PK                     No  
DEPT                 DEPT_NAME_UK                   No  
EMP                  EMP_ID_PK                      Yes 
EMP                  EMP_USERID_UK                  Yes  
IMAGE                IMAGE_ID_PK                    No  
INVENTORY            INVENTORY_PRODUCT_ID_PK        No  

「欢迎关注我们的公众号,获取更多技术分享与经验交流。」


文章转载自数据库驾驶舱,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论