• 灵活好用的sql monitoring 脚本 part5


    51.Script: directories.sql

    -- Description  : Displays information about all directories.

    1. [oracle@MaxwellDBA monitoring]$ cat directories.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/directories.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information about all directories.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @directories
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 150
    11. COLUMN owner FORMAT A20
    12. COLUMN directory_name FORMAT A25
    13. COLUMN directory_path FORMAT A80
    14. SELECT *
    15. FROM dba_directories
    16. ORDER BY owner, directory_name;
    17. [oracle@MaxwellDBA monitoring]$

    52.Script: directory_permissions.sql

    -- Description  : Displays permission information about all directories.

    1. [oracle@MaxwellDBA monitoring]$ cat directory_permissions.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/directory_permissions.sql
    4. -- Author : Maxwell
    5. -- Description : Displays permission information about all directories.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @directory_permissions (directory_name)
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 200
    11. COLUMN grantee FORMAT A20
    12. COLUMN owner FORMAT A10
    13. COLUMN grantor FORMAT A20
    14. COLUMN privilege FORMAT A20
    15. SELECT *
    16. FROM dba_tab_privs
    17. WHERE table_name = UPPER('&1');
    18. [oracle@MaxwellDBA monitoring]$

    53.Script: dispatchers.sql

    -- Description  : Displays dispatcher statistics.

    1. [oracle@MaxwellDBA monitoring]$ cat dispatchers.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/dispatchers.sql
    4. -- Author : Maxwell
    5. -- Description : Displays dispatcher statistics.
    6. -- Requirements : Access to the v$ views.
    7. -- Call Syntax : @dispatchers
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 500
    11. SET PAGESIZE 1000
    12. SET VERIFY OFF
    13. SELECT a.name "Name",
    14. a.status "Status",
    15. a.accept "Accept",
    16. a.messages "Total Mesgs",
    17. a.bytes "Total Bytes",
    18. a.owned "Circs Owned",
    19. a.idle "Total Idle Time",
    20. a.busy "Total Busy Time",
    21. Round(a.busy/(a.busy + a.idle),2) "Load"
    22. FROM v$dispatcher a
    23. ORDER BY 1;
    24. SET PAGESIZE 14
    25. SET VERIFY ON
    26. [oracle@MaxwellDBA monitoring]$

    54.Script: error_stack.sql

    -- Description  : Displays contents of the error stack.

    1. [oracle@MaxwellDBA monitoring]$ cat error_stack.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/error_stack.sql
    4. -- Author : Maxwell
    5. -- Description : Displays contents of the error stack.
    6. -- Call Syntax : @error_stack
    7. -- Last Modified: 06-AUG-2022
    8. -- -----------------------------------------------------------------------------------
    9. SET SERVEROUTPUT ON
    10. DECLARE
    11. v_stack VARCHAR2(2000);
    12. BEGIN
    13. v_stack := Dbms_Utility.Format_Error_Stack;
    14. Dbms_Output.Put_Line(v_stack);
    15. END;
    16. /
    17. [oracle@MaxwellDBA monitoring]$
    1. SQL>
    2. SQL> @/home/oracle/oracledba/monitoring/error_stack.sql
    3. PL/SQL procedure successfully completed.
    4. SQL>

    55.Script: errors.sql

    -- Description  : Displays the source line and the associated error after compilation failure.

    1. [oracle@MaxwellDBA monitoring]$ cat errors.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/errors.sql
    4. -- Author : Maxwell
    5. -- Description : Displays the source line and the associated error after compilation failure.
    6. -- Comments : Essentially the same as SHOW ERRORS.
    7. -- Call Syntax : @errors (source-name)
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SELECT To_Char(a.line) || ' - ' || a.text error
    11. FROM user_source a,
    12. user_errors b
    13. WHERE a.name = Upper('&&1')
    14. AND a.name = b.name
    15. AND a.type = b.type
    16. AND a.line = b.line
    17. ORDER BY a.name, a.line;
    18. [oracle@MaxwellDBA monitoring]$

    56.Script: explain.sql

    -- Description  : Displays a tree-style execution plan of the specified statement after it has been explained

    1. [oracle@MaxwellDBA monitoring]$ cat explain.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/explain.sql
    4. -- Author : Maxwell
    5. -- Description : Displays a tree-style execution plan of the specified statement after it has been explained.
    6. -- Requirements : Access to the plan table.
    7. -- Call Syntax : @explain (statement-id)
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET PAGESIZE 100
    11. SET LINESIZE 200
    12. SET VERIFY OFF
    13. COLUMN plan FORMAT A50
    14. COLUMN object_name FORMAT A30
    15. COLUMN object_type FORMAT A15
    16. COLUMN bytes FORMAT 9999999999
    17. COLUMN cost FORMAT 9999999
    18. COLUMN partition_start FORMAT A20
    19. COLUMN partition_stop FORMAT A20
    20. SELECT LPAD(' ', 2 * (level - 1)) ||
    21. DECODE (level,1,NULL,level-1 || '.' || pt.position || ' ') ||
    22. INITCAP(pt.operation) ||
    23. DECODE(pt.options,NULL,'',' (' || INITCAP(pt.options) || ')') plan,
    24. pt.object_name,
    25. pt.object_type,
    26. pt.bytes,
    27. pt.cost,
    28. pt.partition_start,
    29. pt.partition_stop
    30. FROM plan_table pt
    31. START WITH pt.id = 0
    32. AND pt.statement_id = '&1'
    33. CONNECT BY PRIOR pt.id = pt.parent_id
    34. AND pt.statement_id = '&1';
    35. [oracle@MaxwellDBA monitoring]$

    57.Script: file_io.sql

    1. [oracle@MaxwellDBA monitoring]$ cat file_io.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/file_io.sql
    4. -- Author : Maxwell
    5. -- Description : Displays the amount of IO for each datafile.
    6. -- Requirements : Access to the v$ views.
    7. -- Call Syntax : @file_io
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET PAGESIZE 1000
    11. SELECT Substr(d.name,1,50) "File Name",
    12. f.phyblkrd "Blocks Read",
    13. f.phyblkwrt "Blocks Writen",
    14. f.phyblkrd + f.phyblkwrt "Total I/O"
    15. FROM v$filestat f,
    16. v$datafile d
    17. WHERE d.file# = f.file#
    18. ORDER BY f.phyblkrd + f.phyblkwrt DESC;
    19. SET PAGESIZE 18
    20. [oracle@MaxwellDBA monitoring]$

    58.Script: fk_columns.sql

    -- Description  : Displays information on all FKs for the specified schema and table.

    1. [oracle@MaxwellDBA monitoring]$ cat fk_columns.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/fk_columns.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information on all FKs for the specified schema and table.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @fk_columns (schema-name or all) (table-name or all)
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET VERIFY OFF
    11. SET LINESIZE 1000
    12. COLUMN column_name FORMAT A30
    13. COLUMN r_column_name FORMAT A30
    14. SELECT c.constraint_name,
    15. cc.table_name,
    16. cc.column_name,
    17. rcc.table_name AS r_table_name,
    18. rcc.column_name AS r_column_name,
    19. cc.position
    20. FROM dba_constraints c
    21. JOIN dba_cons_columns cc ON c.owner = cc.owner AND c.constraint_name = cc.constraint_name
    22. JOIN dba_cons_columns rcc ON c.owner = rcc.owner AND c.r_constraint_name = rcc.constraint_name AND cc.position = rcc.position
    23. WHERE c.owner = DECODE(UPPER('&1'), 'ALL', c.owner, UPPER('&1'))
    24. AND c.table_name = DECODE(UPPER('&2'), 'ALL', c.table_name, UPPER('&2'))
    25. ORDER BY c.constraint_name, cc.table_name, cc.position;
    26. [oracle@MaxwellDBA monitoring]$

    59.Script: fks.sql

    -- Description  : Displays the constraints on a specific table and those referencing it.

    1. [oracle@MaxwellDBA monitoring]$ cat fks.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/fks.sql
    4. -- Author : Maxwell
    5. -- Description : Displays the constraints on a specific table and those referencing it.
    6. -- Call Syntax : @fks (table-name) (schema)
    7. -- Last Modified: 06-AUG-2022
    8. -- -----------------------------------------------------------------------------------
    9. PROMPT
    10. SET VERIFY OFF
    11. SET FEEDBACK OFF
    12. SET LINESIZE 255
    13. SET PAGESIZE 1000
    14. PROMPT
    15. PROMPT Constraints Owned By Table
    16. PROMPT ==========================
    17. SELECT c.constraint_name "Constraint",
    18. Decode(c.constraint_type,'P','Primary Key',
    19. 'U','Unique Key',
    20. 'C','Check',
    21. 'R','Foreign Key',
    22. c.constraint_type) "Type",
    23. c.r_owner "Ref Table",
    24. c.r_constraint_name "Ref Constraint"
    25. FROM all_constraints c
    26. WHERE c.table_name = Upper('&&1')
    27. AND c.owner = Upper('&&2');
    28. PROMPT
    29. PROMPT Constraints Referencing Table
    30. PROMPT =============================
    31. SELECT c1.table_name "Table",
    32. c1.constraint_name "Foreign Key",
    33. c1.r_constraint_name "References"
    34. FROM all_constraints c1
    35. WHERE c1.owner = Upper('&&2')
    36. AND c1.r_constraint_name IN (SELECT c2.constraint_name
    37. FROM all_constraints c2 WHERE c2.table_name = Upper('&&1')
    38. AND c2.owner = Upper('&&2')
    39. AND c2.constraint_type IN ('P','U'));
    40. SET VERIFY ON
    41. SET FEEDBACK ON
    42. SET PAGESIZE 1000
    43. PROMPT
    44. [oracle@MaxwellDBA monitoring]$

     

    60.Script: free_space.sql

    -- Description  : Displays space usage for each datafile.

    1. [oracle@MaxwellDBA monitoring]$ cat free_space.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/free_space.sql
    4. -- Author : Maxwell
    5. -- Description : Displays space usage for each datafile.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @free_space
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET PAGESIZE 100
    11. SET LINESIZE 265
    12. COLUMN tablespace_name FORMAT A20
    13. COLUMN file_name FORMAT A50
    14. SELECT df.tablespace_name,
    15. df.file_name,
    16. df.size_mb,
    17. f.free_mb,
    18. df.max_size_mb,
    19. f.free_mb + (df.max_size_mb - df.size_mb) AS max_free_mb,
    20. RPAD(' '|| RPAD('X',ROUND((df.max_size_mb-(f.free_mb + (df.max_size_mb - df.size_mb)))/max_size_mb*10,0), 'X'),11,'-') AS used_pct
    21. FROM (SELECT file_id,
    22. file_name,
    23. tablespace_name,
    24. TRUNC(bytes/1024/1024) AS size_mb,
    25. TRUNC(GREATEST(bytes,maxbytes)/1024/1024) AS max_size_mb
    26. FROM dba_data_files) df,
    27. (SELECT TRUNC(SUM(bytes)/1024/1024) AS free_mb,
    28. file_id
    29. FROM dba_free_space
    30. GROUP BY file_id) f
    31. WHERE df.file_id = f.file_id (+)
    32. ORDER BY df.tablespace_name,
    33. df.file_name;
    34. PROMPT
    35. SET PAGESIZE 14
    36. [oracle@MaxwellDBA monitoring]$

    61.Script: health.sql

    -- Description  : Lots of information about the database so you can asses the general health of the system.

    1. [oracle@MaxwellDBA monitoring]$ cat health.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/health.sql
    4. -- Author : Maxwell
    5. -- Description : Lots of information about the database so you can asses the general health of the system.
    6. -- Requirements : Access to the V$ & DBA views and several other monitoring scripts.
    7. -- Call Syntax : @health (username/password@service)
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SPOOL Health_Checks.txt
    11. conn &1
    12. @db_info
    13. @sessions
    14. @ts_full
    15. @max_extents
    16. SPOOL OFF
    17. [oracle@MaxwellDBA monitoring]$

    62.Script: hidden_parameters.sql

    -- Description  : Displays a list of one or all the hidden parameters.

    1. [oracle@MaxwellDBA monitoring]$ cat hidden_parameters.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/hidden_parameters.sql
    4. -- Author : Maxwell
    5. -- Description : Displays a list of one or all the hidden parameters.
    6. -- Requirements : Access to the v$ views.
    7. -- Call Syntax : @hidden_parameters (parameter-name or all)
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET VERIFY OFF
    11. COLUMN parameter FORMAT a37
    12. COLUMN description FORMAT a30 WORD_WRAPPED
    13. COLUMN session_value FORMAT a10
    14. COLUMN instance_value FORMAT a10
    15. SELECT a.ksppinm AS parameter,
    16. a.ksppdesc AS description,
    17. b.ksppstvl AS session_value,
    18. c.ksppstvl AS instance_value
    19. FROM x$ksppi a,
    20. x$ksppcv b,
    21. x$ksppsv c
    22. WHERE a.indx = b.indx
    23. AND a.indx = c.indx
    24. AND a.ksppinm LIKE '/_%' ESCAPE '/'
    25. AND a.ksppinm = DECODE(LOWER('&1'), 'all', a.ksppinm, LOWER('&1'))
    26. ORDER BY a.ksppinm;
    27. [oracle@MaxwellDBA monitoring]$

    63.Script: high_water_mark.sql

    -- Description  : Displays the High Water Mark for the specified table, or all tables.

    1. [oracle@MaxwellDBA monitoring]$ cat high_water_mark.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/high_water_mark.sql
    4. -- Author : Maxwell
    5. -- Description : Displays the High Water Mark for the specified table, or all tables.
    6. -- Requirements : Access to the Dbms_Space.
    7. -- Call Syntax : @high_water_mark (table_name or all) (schema-name)
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET SERVEROUTPUT ON
    11. SET VERIFY OFF
    12. DECLARE
    13. CURSOR cu_tables IS
    14. SELECT a.owner,
    15. a.table_name
    16. FROM all_tables a
    17. WHERE a.table_name = Decode(Upper('&&1'),'ALL',a.table_name,Upper('&&1'))
    18. AND a.owner = Upper('&&2');
    19. op1 NUMBER;
    20. op2 NUMBER;
    21. op3 NUMBER;
    22. op4 NUMBER;
    23. op5 NUMBER;
    24. op6 NUMBER;
    25. op7 NUMBER;
    26. BEGIN
    27. Dbms_Output.Disable;
    28. Dbms_Output.Enable(1000000);
    29. Dbms_Output.Put_Line('TABLE UNUSED BLOCKS TOTAL BLOCKS HIGH WATER MARK');
    30. Dbms_Output.Put_Line('------------------------------ --------------- --------------- ---------------');
    31. FOR cur_rec IN cu_tables LOOP
    32. Dbms_Space.Unused_Space(cur_rec.owner,cur_rec.table_name,'TABLE',op1,op2,op3,op4,op5,op6,op7);
    33. Dbms_Output.Put_Line(RPad(cur_rec.table_name,30,' ') ||
    34. LPad(op3,15,' ') ||
    35. LPad(op1,15,' ') ||
    36. LPad(Trunc(op1-op3-1),15,' '));
    37. END LOOP;
    38. END;
    39. /
    40. SET VERIFY ON
    41. [oracle@MaxwellDBA monitoring]$

    64.Script: hot_blocks.sql

    -- Description  : Detects hot blocks.

    1. -- -----------------------------------------------------------------------------------
    2. -- File Name : /monitoring/hot_blocks.sql
    3. -- Author : Maxwell
    4. -- Description : Detects hot blocks.
    5. -- Call Syntax : @hot_blocks
    6. -- Last Modified: 06-AUG-2022
    7. -- -----------------------------------------------------------------------------------
    8. SET LINESIZE 200
    9. SET VERIFY OFF
    10. SELECT *
    11. FROM (SELECT name,
    12. addr,
    13. gets,
    14. misses,
    15. sleeps
    16. FROM v$latch_children
    17. WHERE name = 'cache buffers chains'
    18. AND misses > 0
    19. ORDER BY misses DESC)
    20. WHERE rownum < 11;
    21. ACCEPT address PROMPT "Enter ADDR: "
    22. COLUMN owner FORMAT A15
    23. COLUMN object_name FORMAT A30
    24. COLUMN subobject_name FORMAT A20
    25. SELECT *
    26. FROM (SELECT o.owner,
    27. o.object_name,
    28. o.subobject_name,
    29. bh.tch,
    30. bh.obj,
    31. bh.file#,
    32. bh.dbablk,
    33. bh.class,
    34. bh.state
    35. FROM x$bh bh,
    36. dba_objects o
    37. WHERE o.data_object_id = bh.obj
    38. AND hladdr = '&address'
    39. ORDER BY tch DESC)
    40. WHERE rownum < 11;

    65.Script: identify_trace_file.sql

    -- Description  : Displays the name of the trace file associated with the current session.

    1. [oracle@MaxwellDBA monitoring]$ cat identify_trace_file.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/identify_trace_file.sql
    4. -- Author : Maxwell
    5. -- Description : Displays the name of the trace file associated with the current session.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @identify_trace_file
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 100
    11. COLUMN trace_file FORMAT A60
    12. SELECT s.sid,
    13. s.serial#,
    14. pa.value || '/' || LOWER(SYS_CONTEXT('userenv','instance_name')) ||
    15. '_ora_' || p.spid || '.trc' AS trace_file
    16. FROM v$session s,
    17. v$process p,
    18. v$parameter pa
    19. WHERE pa.name = 'user_dump_dest'
    20. AND s.paddr = p.addr
    21. AND s.audsid = SYS_CONTEXT('USERENV', 'SESSIONID');
    22. [oracle@MaxwellDBA monitoring]$

    66.Script: index_extents.sql

    -- Description  : Displays number of extents for all indexes belonging to the specified table, or all tables.

    1. [oracle@MaxwellDBA monitoring]$ cat index_extents.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/index_extents.sql
    4. -- Author : Maxwell
    5. -- Description : Displays number of extents for all indexes belonging to the specified table, or all tables.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @index_extents (table_name or all) (schema-name)
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 500
    11. SET PAGESIZE 1000
    12. SET VERIFY OFF
    13. SELECT i.index_name,
    14. Count(e.segment_name) extents,
    15. i.max_extents,
    16. t.num_rows "ROWS",
    17. Trunc(i.initial_extent/1024) "INITIAL K",
    18. Trunc(i.next_extent/1024) "NEXT K",
    19. t.table_name
    20. FROM all_tables t,
    21. all_indexes i,
    22. dba_extents e
    23. WHERE i.table_name = t.table_name
    24. AND i.owner = t.owner
    25. AND e.segment_name = i.index_name
    26. AND e.owner = i.owner
    27. AND i.table_name = Decode(Upper('&&1'),'ALL',i.table_name,Upper('&&1'))
    28. AND i.owner = Upper('&&2')
    29. GROUP BY t.table_name,
    30. i.index_name,
    31. i.max_extents,
    32. t.num_rows,
    33. i.initial_extent,
    34. i.next_extent
    35. HAVING Count(e.segment_name) > 5
    36. ORDER BY Count(e.segment_name) DESC;
    37. SET PAGESIZE 18
    38. SET VERIFY ON
    39. [oracle@MaxwellDBA monitoring]$

    67.Script: index_monitoring_status.sql

    -- Description  : Shows the monitoring status for the specified table indexes.

    1. [oracle@MaxwellDBA monitoring]$ cat index_monitoring_status.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/index_monitoring_status.sql
    4. -- Author : Maxwell
    5. -- Description : Shows the monitoring status for the specified table indexes.
    6. -- Call Syntax : @index_monitoring_status (table-name) (index-name or all)
    7. -- Last Modified: 06-AUG-2022
    8. -- -----------------------------------------------------------------------------------
    9. SET VERIFY OFF
    10. SELECT table_name,
    11. index_name,
    12. monitoring
    13. FROM v$object_usage
    14. WHERE table_name = UPPER('&1')
    15. AND index_name = DECODE(UPPER('&2'), 'ALL', index_name, UPPER('&2'));
    16. [oracle@MaxwellDBA monitoring]$

    68.Script: index_partitions.sql

    -- Description  : Displays partition information for the specified index, or all indexes.

    1. [oracle@MaxwellDBA monitoring]$ cat index_partitions.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/index_partitions.sql
    4. -- Author : Maxwell
    5. -- Description : Displays partition information for the specified index, or all indexes.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @index_patitions (index_name or all) (schema-name)
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 500
    11. SET PAGESIZE 1000
    12. SET FEEDBACK OFF
    13. SET VERIFY OFF
    14. SELECT a.index_name,
    15. a.partition_name,
    16. a.tablespace_name,
    17. a.initial_extent,
    18. a.next_extent,
    19. a.pct_increase,
    20. a.num_rows
    21. FROM dba_ind_partitions a
    22. WHERE a.index_name = Decode(Upper('&&1'),'ALL',a.index_name,Upper('&&1'))
    23. AND a.index_owner = Upper('&&2')
    24. ORDER BY a.index_name, a.partition_name
    25. /
    26. PROMPT
    27. SET PAGESIZE 14
    28. SET FEEDBACK ON
    29. [oracle@MaxwellDBA monitoring]$

    69.Script: index_usage.sql

    -- Description  : Shows the usage for the specified table indexes.

    1. [oracle@MaxwellDBA monitoring]$ cat index_usage.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/index_usage.sql
    4. -- Author : Maxwell
    5. -- Description : Shows the usage for the specified table indexes.
    6. -- Call Syntax : @index_usage (table-name) (index-name or all)
    7. -- Last Modified: 06-AUG-2022
    8. -- -----------------------------------------------------------------------------------
    9. SET VERIFY OFF
    10. SET LINESIZE 200
    11. SELECT table_name,
    12. index_name,
    13. used,
    14. start_monitoring,
    15. end_monitoring
    16. FROM v$object_usage
    17. WHERE table_name = UPPER('&1')
    18. AND index_name = DECODE(UPPER('&2'), 'ALL', index_name, UPPER('&2'));
    19. [oracle@MaxwellDBA monitoring]$

    70.Script: invalid_objects.sql

    -- Description  : Lists all invalid objects in the database.

    1. [oracle@MaxwellDBA monitoring]$ cat invalid_objects.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/invalid_objects.sql
    4. -- Author : Maxwell
    5. -- Description : Lists all invalid objects in the database.
    6. -- Call Syntax : @invalid_objects
    7. -- Requirements : Access to the DBA views.
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. COLUMN owner FORMAT A30
    11. COLUMN object_name FORMAT A30
    12. SELECT owner,
    13. object_type,
    14. object_name,
    15. status
    16. FROM dba_objects
    17. WHERE status = 'INVALID'
    18. ORDER BY owner, object_type, object_name;
    19. [oracle@MaxwellDBA monitoring]$
  • 相关阅读:
    事务码ABAVN-资产卡片报废-BAPI_ASSET_RETIREMENT_POST
    java计算机毕业设计招聘信息系统源程序+mysql+系统+lw文档+远程调试
    python多线程系列—线程池ThreadPoolExecutor(八)
    [C#] 允许当前应用程序通过防火墙
    Django-中间件(切面编程AOP)
    SpringCloud搭建保姆级教程
    第 1 课 Python 的输出!
    排序算法:选择排序(直接选择排序、堆排序)
    易基因|干货:m6A RNA甲基化MeRIP-seq测序分析实验全流程解析
    CSS阴影优化气泡框样式
  • 原文地址:https://blog.csdn.net/u011868279/article/details/126199066