-- Description : Displays all dependencies of specified object.
- [oracle@MaxwellDBA monitoring]$ cat code_dep.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/code_dep.sql
- -- Author : Maxwell
- -- Description : Displays all dependencies of specified object.
- -- Call Syntax : @code_dep (schema-name or all) (object-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET VERIFY OFF
- SET LINESIZE 255
- SET PAGESIZE 1000
- BREAK ON referenced_type SKIP 1
-
- COLUMN referenced_type FORMAT A20
- COLUMN referenced_owner FORMAT A20
- COLUMN referenced_name FORMAT A40
- COLUMN referenced_link_name FORMAT A20
-
- SELECT a.referenced_type,
- a.referenced_owner,
- a.referenced_name,
- a.referenced_link_name
- FROM all_dependencies a
- WHERE a.owner = DECODE(UPPER('&1'), 'ALL', a.referenced_owner, UPPER('&1'))
- AND a.name = UPPER('&2')
- ORDER BY 1,2,3;
-
- SET VERIFY ON
- SET PAGESIZE 22
- [oracle@MaxwellDBA monitoring]$
- SQL> @/home/oracle/oracledba/monitoring/code_dep.sql SYS USER$
-
- no rows selected
-
- SQL> @/home/oracle/oracledba/monitoring/code_dep.sql ALL USER$
-
- no rows selected
-
- SQL> @/home/oracle/oracledba/monitoring/code_dep.sql ALL ALL
-
- no rows selected
-
- SQL>
-- Description : Displays a tree of dependencies of specified object.
- [oracle@MaxwellDBA monitoring]$ cat code_dep_distinct.sql
-
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/code_dep_distinct.sql
- -- Author : Maxwell
- -- Description : Displays a tree of dependencies of specified object.
- -- Call Syntax : @code_dep_distinct (schema-name) (object-name) (object_type or all)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET VERIFY OFF
- SET LINESIZE 255
- SET PAGESIZE 1000
-
- COLUMN referenced_object FORMAT A50
- COLUMN referenced_type FORMAT A20
- COLUMN referenced_link_name FORMAT A20
-
- SELECT DISTINCT a.referenced_owner || '.' || a.referenced_name AS referenced_object,
- a.referenced_type,
- a.referenced_link_name
- FROM all_dependencies a
- WHERE a.owner NOT IN ('SYS','SYSTEM','PUBLIC')
- AND a.referenced_owner NOT IN ('SYS','SYSTEM','PUBLIC')
- AND a.referenced_type != 'NON-EXISTENT'
- AND a.referenced_type = DECODE(UPPER('&3'), 'ALL', a.referenced_type, UPPER('&3'))
- START WITH a.owner = UPPER('&1')
- AND a.name = UPPER('&2')
- CONNECT BY a.owner = PRIOR a.referenced_owner
- AND a.name = PRIOR a.referenced_name
- AND a.type = PRIOR a.referenced_type;
-
- SET VERIFY ON
- SET PAGESIZE 22
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays all objects dependant on the specified object.
- [oracle@MaxwellDBA monitoring]$ cat code_dep_on.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/code_dep_on.sql
- -- Author : Maxwell
- -- Description : Displays all objects dependant on the specified object.
- -- Call Syntax : @code_dep_on (schema-name or all) (object-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET VERIFY OFF
- SET LINESIZE 255
- SET PAGESIZE 1000
- BREAK ON type SKIP 1
-
- COLUMN owner FORMAT A20
-
- SELECT a.type,
- a.owner,
- a.name
- FROM all_dependencies a
- WHERE a.referenced_owner = DECODE(UPPER('&1'), 'ALL', a.referenced_owner, UPPER('&1'))
- AND a.referenced_name = UPPER('&2')
- ORDER BY 1,2,3;
-
- SET PAGESIZE 22
- SET VERIFY ON
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays a tree of dependencies of specified object.
- [oracle@MaxwellDBA monitoring]$ cat code_dep_tree.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/code_dep_tree.sql
- -- Author : Maxwell
- -- Description : Displays a tree of dependencies of specified object.
- -- Call Syntax : @code_dep_tree (schema-name) (object-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET VERIFY OFF
- SET LINESIZE 255
- SET PAGESIZE 1000
-
- COLUMN referenced_object FORMAT A50
- COLUMN referenced_type FORMAT A20
- COLUMN referenced_link_name FORMAT A20
-
- SELECT RPAD(' ', level*2, ' ') || a.referenced_owner || '.' || a.referenced_name AS referenced_object,
- a.referenced_type,
- a.referenced_link_name
- FROM all_dependencies a
- WHERE a.owner NOT IN ('SYS','SYSTEM','PUBLIC')
- AND a.referenced_owner NOT IN ('SYS','SYSTEM','PUBLIC')
- AND a.referenced_type != 'NON-EXISTENT'
- START WITH a.owner = UPPER('&1')
- AND a.name = UPPER('&2')
- CONNECT BY a.owner = PRIOR a.referenced_owner
- AND a.name = PRIOR a.referenced_name
- AND a.type = PRIOR a.referenced_type;
-
- SET VERIFY ON
- SET PAGESIZE 22
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays a list of locked objects.
- [oracle@MaxwellDBA monitoring]$ cat obj_lock.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/obj_lock.sql
- -- Author : Maxwell
- -- Description : Displays a list of locked objects.
- -- Requirements : Access to the V$ views.
- -- Call Syntax : @obj_lock
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SELECT a.type,
- Substr(a.owner,1,30) owner,
- a.sid,
- Substr(a.object,1,30) object
- FROM v$access a
- WHERE a.owner NOT IN ('SYS','PUBLIC')
- ORDER BY 1,2,3,4
- /
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays object privileges on a specified object.
- [oracle@MaxwellDBA monitoring]$ cat object_privs.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/object_privs.sql
- -- Author : Maxwell
- -- Description : Displays object privileges on a specified object.
- -- Requirements : Access to the DBA views.
- -- Call Syntax : @object_privs (owner) (object-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET LINESIZE 200 VERIFY OFF
-
- COLUMN owner FORMAT A30
- COLUMN object_name FORMAT A30
- COLUMN grantor FORMAT A30
- COLUMN grantee FORMAT A30
-
- SELECT owner,
- table_name AS object_name,
- grantor,
- grantee,
- privilege,
- grantable,
- hierarchy
- FROM dba_tab_privs
- WHERE owner = UPPER('&1')
- AND table_name = UPPER('&2')
- ORDER BY 1,2,3,4;
-
- SET VERIFY ON
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays a list of objects and their status for the specific schema.
- [oracle@MaxwellDBA monitoring]$ cat object_status.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/object_status.sql
- -- Author : Maxwell
- -- Description : Displays a list of objects and their status for the specific schema.
- -- Requirements : Access to the ALL views.
- -- Call Syntax : @object_status (schema-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET SERVEROUTPUT ON
- SET PAGESIZE 1000
- SET LINESIZE 255
- SET FEEDBACK OFF
- SET VERIFY OFF
-
- SELECT Substr(object_name,1,30) object_name,
- object_type,
- status
- FROM all_objects
- WHERE owner = Upper('&&1');
-
- PROMPT
- SET FEEDBACK ON
- SET PAGESIZE 18
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays information about all database objects.
- [oracle@MaxwellDBA monitoring]$ cat objects.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/objects.sql
- -- Author : Maxwell
- -- Description : Displays information about all database objects.
- -- Requirements : Access to the dba_objects view.
- -- Call Syntax : @objects [ object-name | % (for all)]
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET LINZESIZE 200 VERIFY OFF
-
- COLUMN owner FORMAT A20
- COLUMN object_name FORMAT A30
- COLUMN edition_name FORMAT A15
-
-
- SELECT owner,
- object_name,
- -- subobject_name,
- object_id,
- data_object_id,
- object_type,
- TO_CHAR(created, 'DD-MON-YYYY HH24:MI:SS') AS created,
- TO_CHAR(last_ddl_time, 'DD-MON-YYYY HH24:MI:SS') AS last_ddl_time,
- timestamp,
- status,
- temporary,
- generated,
- secondary,
- --namespace,
- edition_name
- FROM dba_objects
- WHERE UPPER(object_name) LIKE UPPER('%&1%')
- ORDER BY owner,object_name;
-
- SET VERIFY ON
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays current statistics preferences.
- [oracle@MaxwellDBA monitoring]$ cat statistics_prefs.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/statistics_prefs.sql
- -- Author : Maxwell
- -- Description : Displays current statistics preferences.
- -- Requirements : Access to the DBMS_STATS package.
- -- Call Syntax : @statistics_prefs
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
-
- SET LINESIZE 250
-
- COLUMN autostats_target FORMAT A20
- COLUMN cascade FORMAT A25
- COLUMN degree FORMAT A10
- COLUMN estimate_percent FORMAT A30
- COLUMN method_opt FORMAT A25
- COLUMN no_invalidate FORMAT A30
- COLUMN granularity FORMAT A15
- COLUMN publish FORMAT A10
- COLUMN incremental FORMAT A15
- COLUMN stale_percent FORMAT A15
-
- SELECT DBMS_STATS.GET_PREFS('AUTOSTATS_TARGET') AS autostats_target,
- DBMS_STATS.GET_PREFS('CASCADE') AS cascade,
- DBMS_STATS.GET_PREFS('DEGREE') AS degree,
- DBMS_STATS.GET_PREFS('ESTIMATE_PERCENT') AS estimate_percent,
- DBMS_STATS.GET_PREFS('METHOD_OPT') AS method_opt,
- DBMS_STATS.GET_PREFS('NO_INVALIDATE') AS no_invalidate,
- DBMS_STATS.GET_PREFS('GRANULARITY') AS granularity,
- DBMS_STATS.GET_PREFS('PUBLISH') AS publish,
- DBMS_STATS.GET_PREFS('INCREMENTAL') AS incremental,
- DBMS_STATS.GET_PREFS('STALE_PERCENT') AS stale_percent
- FROM dual;
- [oracle@MaxwellDBA monitoring]$
-
- SQL> @/home/oracle/oracledba/monitoring/statistics_prefs.sql
-
- AUTOSTATS_TARGET CASCADE DEGREE ESTIMATE_PERCENT METHOD_OPT NO_INVALIDATE GRANULARITY PUBLISH INCREMENTAL STALE_PERCENT
- -------------------- ------------------------- ---------- ------------------------------ ------------------------- ------------------------------ --------------- ---------- --------------- ---------------
- AUTO DBMS_STATS.AUTO_CASCADE NULL DBMS_STATS.AUTO_SAMPLE_SIZE FOR ALL COLUMNS SIZE AUTO DBMS_STATS.AUTO_INVALIDATE AUTO TRUE FALSE 10
-
- 1 row selected.
-
- SQL>
-- Description : Lists all synonyms that point to missing objects.
- [oracle@MaxwellDBA monitoring]$ cat synonyms_to_missing_objects.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/synonyms_to_missing_objects.sql
- -- Author : Maxwell
- -- Description : Lists all synonyms that point to missing objects.
- -- Call Syntax : @synonyms_to_missing_objects(object-schema-name or all)
- -- Requirements : Access to the DBA views.
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET LINESIZE 1000 VERIFY OFF
-
- SELECT s.owner,
- s.synonym_name,
- s.table_owner,
- s.table_name
- FROM dba_synonyms s
- WHERE s.db_link IS NULL
- AND s.table_owner NOT IN ('SYS','SYSTEM')
- AND NOT EXISTS (SELECT 1
- FROM dba_objects o
- WHERE o.owner = s.table_owner
- AND o.object_name = s.table_name
- AND o.object_type != 'SYNONYM')
- AND s.table_owner = DECODE(UPPER('&1'), 'ALL', s.table_owner, UPPER('&1'))
- ORDER BY s.owner, s.synonym_name;
-
- SET LINESIZE 80 VERIFY ON
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays information on all system events.
- [oracle@MaxwellDBA monitoring]$ cat system_events.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/system_events.sql
- -- Author : Maxwell
- -- Description : Displays information on all system events.
- -- Requirements : Access to the V$ views.
- -- Call Syntax : @system_events
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SELECT event,
- total_waits,
- total_timeouts,
- time_waited,
- average_wait,
- time_waited_micro
- FROM v$system_event
- ORDER BY event;
- [oracle@MaxwellDBA monitoring]$

-- Description : Displays a list of all the system parameters.
- [oracle@MaxwellDBA monitoring]$ cat system_parameters.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/system_parameters.sql
- -- Author : Maxwell
- -- Description : Displays a list of all the system parameters.
- -- Comment out isinstance_modifiable for use prior to 10g.
- -- Requirements : Access to the v$ views.
- -- Call Syntax : @system_parameters
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET LINESIZE 500
-
- COLUMN name FORMAT A30
- COLUMN value FORMAT A60
-
- SELECT sp.name,
- sp.type,
- sp.value,
- sp.isses_modifiable,
- sp.issys_modifiable,
- sp.isinstance_modifiable
- FROM v$system_parameter sp
- ORDER BY sp.name;
- [oracle@MaxwellDBA monitoring]$

-- Description : Displays users granted the specified system privilege.
- [oracle@MaxwellDBA monitoring]$ cat system_privs.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/system_privs.sql
- -- Author : Maxwell
- -- Description : Displays users granted the specified system privilege.
- -- Requirements : Access to the DBA views.
- -- Call Syntax : @system_privs ("sys-priv")
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET LINESIZE 200 VERIFY OFF
-
- SELECT privilege,
- grantee,
- admin_option
- FROM dba_sys_privs
- WHERE privilege LIKE UPPER('%&1%')
- ORDER BY privilege, grantee;
-
- SET VERIFY ON
- [oracle@MaxwellDBA monitoring]$

-- Description : Displays system statistics.
- [oracle@MaxwellDBA monitoring]$ cat system_stats.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/system_stats.sql
- -- Author : Maxwell
- -- Description : Displays system statistics.
- -- Requirements : Access to the V$ views.
- -- Call Syntax : @system_stats (statistic-name or all)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET VERIFY OFF
-
- COLUMN name FORMAT A50
- COLUMN value FORMAT 99999999999999999999
-
- SELECT sn.name, ss.value
- FROM v$sysstat ss,
- v$statname sn
- WHERE ss.statistic# = sn.statistic#
- AND sn.name LIKE '%' || DECODE(LOWER('&1'), 'all', '', LOWER('&1')) || '%';
- [oracle@MaxwellDBA monitoring]$

-- Description : Displays a list dependencies for the specified table.
- [oracle@MaxwellDBA monitoring]$ cat table_dep.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/table_dep.sql
- -- Author : Maxwell
- -- Description : Displays a list dependencies for the specified table.
- -- Requirements : Access to the ALL views.
- -- Call Syntax : @table_dep (table-name) (schema-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- PROMPT
- SET VERIFY OFF
- SET FEEDBACK OFF
- SET LINESIZE 255
- SET PAGESIZE 1000
-
-
- SELECT ad.referenced_name "Object",
- ad.name "Ref Object",
- ad.type "Type",
- Substr(ad.referenced_owner,1,10) "Ref Owner",
- Substr(ad.referenced_link_name,1,20) "Ref Link Name"
- FROM all_dependencies ad
- WHERE ad.referenced_name = Upper('&&1')
- AND ad.owner = Upper('&&2')
- ORDER BY 1,2,3;
-
- SET VERIFY ON
- SET FEEDBACK ON
- SET PAGESIZE 14
- PROMPT
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays a list of tables having more than 1 extent.
- [oracle@MaxwellDBA monitoring]$ cat table_extents.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/table_extents.sql
- -- Author : Maxwell
- -- Description : Displays a list of tables having more than 1 extent.
- -- Requirements : Access to the DBA views.
- -- Call Syntax : @table_extents (schema-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET LINESIZE 500
- SET PAGESIZE 1000
- SET VERIFY OFF
-
- SELECT t.table_name,
- Count(e.segment_name) extents,
- t.max_extents,
- t.num_rows "ROWS",
- Trunc(t.initial_extent/1024) "INITIAL K",
- Trunc(t.next_extent/1024) "NEXT K"
- FROM all_tables t,
- dba_extents e
- WHERE e.segment_name = t.table_name
- AND e.owner = t.owner
- AND t.owner = Upper('&&1')
- GROUP BY t.table_name,
- t.max_extents,
- t.num_rows,
- t.initial_extent,
- t.next_extent
- HAVING Count(e.segment_name) > 1
- ORDER BY Count(e.segment_name) DESC;
-
- SET PAGESIZE 18
- SET VERIFY ON
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays information on all active database sessions.
- [oracle@MaxwellDBA monitoring]$ cat table_growth.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/table_growth.sql
- -- Author : Maxwell
- -- Description : Displays information on all active database sessions.
- -- Requirements : Access to the DBA_HIST views. Diagnostics and Tuning license.
- -- Call Syntax : @table_growth (schema-name) (table_name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- COLUMN object_name FORMAT A30
-
- SELECT TO_CHAR(sn.begin_interval_time,'DD-MON-YYYY HH24:MM') AS begin_interval_time,
- sso.object_name,
- ss.space_used_total
- FROM dba_hist_seg_stat ss,
- dba_hist_seg_stat_obj sso,
- dba_hist_snapshot sn
- WHERE sso.owner = UPPER('&1')
- AND sso.obj# = ss.obj#
- AND sn.snap_id = ss.snap_id
- AND sso.object_name LIKE UPPER('&2') || '%'
- ORDER BY sn.begin_interval_time;
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays index-column information for the specified table.
- [oracle@MaxwellDBA monitoring]$ cat table_indexes.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/table_indexes.sql
- -- Author : Maxwell
- -- Description : Displays index-column information for the specified table.
- -- Requirements : Access to the DBA views.
- -- Call Syntax : @table_indexes (schema-name) (table-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET LINESIZE 500 PAGESIZE 1000 VERIFY OFF
-
- COLUMN index_name FORMAT A30
- COLUMN column_name FORMAT A30
- COLUMN column_position FORMAT 99999
-
- SELECT a.index_name,
- a.column_name,
- a.column_position
- FROM all_ind_columns a,
- all_indexes b
- WHERE b.owner = UPPER('&1')
- AND b.table_name = UPPER('&2')
- AND b.index_name = a.index_name
- AND b.owner = a.index_owner
- ORDER BY 1,3;
-
- SET PAGESIZE 18 VERIFY ON
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays partition information for the specified table, or all tables.
- [oracle@MaxwellDBA monitoring]$ cat table_partitions.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/table_partitions.sql
- -- Author : Maxwell
- -- Description : Displays partition information for the specified table, or all tables.
- -- Requirements : Access to the DBA views.
- -- Call Syntax : @table_partitions (table-name or all) (schema-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET LINESIZE 500
- SET PAGESIZE 1000
- SET FEEDBACK OFF
- SET VERIFY OFF
-
- SELECT a.table_name,
- a.partition_name,
- a.tablespace_name,
- a.initial_extent,
- a.next_extent,
- a.pct_increase,
- a.num_rows,
- a.avg_row_len
- FROM dba_tab_partitions a
- WHERE a.table_name = Decode(Upper('&&1'),'ALL',a.table_name,Upper('&&1'))
- AND a.table_owner = Upper('&&2')
- ORDER BY a.table_name, a.partition_name
- /
-
-
- SET PAGESIZE 14
- SET FEEDBACK ON
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays the table statistics belonging to the specified schema.
- [oracle@MaxwellDBA monitoring]$ cat table_stats.sql
- -- File Name : /monitoring/table_stats.sql
- -- Author : Maxwell
- -- Description : Displays the table statistics belonging to the specified schema.
- -- Requirements : Access to the DBA and v$ views.
- -- Call Syntax : @table_stats (schema-name) (table-name)
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
- SET LINESIZE 300 VERIFY OFF
-
- COLUMN owner FORMAT A20
- COLUMN table_name FORMAT A30
- COLUMN index_name FORMAT A30
-
- SELECT owner,
- table_name,
- num_rows,
- blocks,
- empty_blocks,
- avg_space
- chain_cnt,
- avg_row_len,
- last_analyzed
- FROM dba_tables
- WHERE owner = UPPER('&1')
- AND table_name = UPPER('&2');
-
- SELECT index_name,
- blevel,
- leaf_blocks,
- distinct_keys,
- avg_leaf_blocks_per_key,
- avg_data_blocks_per_key,
- clustering_factor,
- num_rows,
- last_analyzed
- FROM dba_indexes
- WHERE table_owner = UPPER('&1')
- AND table_name = UPPER('&2')
- ORDER BY index_name;
-
- COLUMN column_name FORMAT A30
- COLUMN low_value FORMAT A40
- COLUMN high_value FORMAT A40
- COLUMN endpoint_actual_value FORMAT A30
-
- SELECT column_id,
- column_name,
- num_distinct,
- avg_col_len,
- histogram,
- low_value,
- high_value
- FROM dba_tab_columns
- WHERE owner = UPPER('&1')
- AND table_name = UPPER('&2')
- ORDER BY column_id;
-
- SET VERIFY ON
- [oracle@MaxwellDBA monitoring]$
-- Description : Lists the triggers for the specified table.
- [oracle@MaxwellDBA monitoring]$ cat table_triggers.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/table_triggers.sql
- -- Author : Maxwell
- -- Description : Lists the triggers for the specified table.
- -- Call Syntax : @table_triggers (schema) (table_name)
- -- Last Modified: 05-AUG-22
- -- -----------------------------------------------------------------------------------
- SELECT owner,
- trigger_name,
- status
- FROM dba_triggers
- WHERE table_owner = UPPER('&1')
- AND table_name = UPPER('&2');
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays tables with locked stats.
- [oracle@MaxwellDBA monitoring]$ cat tables_with_locked_stats.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/tables_with_locked_stats.sql
- -- Author : Maxwell
- -- Description : Displays tables with locked stats.
- -- Requirements : Access to the DBA views.
- -- Call Syntax : @tables_with_locked_stats.sql
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
-
- SELECT owner,
- table_name,
- stattype_locked
- FROM dba_tab_statistics
- WHERE stattype_locked IS NOT NULL
- ORDER BY owner, table_name;
- [oracle@MaxwellDBA monitoring]$
-- Description : Displays tables with stats saying they have zero rows.
- [oracle@MaxwellDBA monitoring]$ cat tables_with_zero_rows.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/tables_with_zero_rows.sql
- -- Author : Maxwell
- -- Description : Displays tables with stats saying they have zero rows.
- -- Requirements : Access to the DBA views.
- -- Call Syntax : @tables_with_zero_rows.sql
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
-
- SELECT owner,
- table_name,
- last_analyzed,
- num_rows
- FROM dba_tables
- WHERE num_rows = 0
- AND owner NOT IN ('SYS','SYSTEM','SYSMAN','XDB','MDSYS',
- 'WMSYS','OUTLN','ORDDATA','ORDSYS',
- 'OLAPSYS','EXFSYS','DBNSMP','CTXSYS',
- 'APEX_030200','FLOWS_FILES','SCOTT',
- 'TSMSYS','DBSNMP','APPQOSSYS','OWBSYS',
- 'DMSYS','FLOWS_030100','WKSYS','WK_TEST')
- ORDER BY owner, table_name;
- [oracle@MaxwellDBA monitoring]$

-- Description : Displays information about tablespaces.
- [oracle@MaxwellDBA monitoring]$ cat tablespaces.sql
- -- -----------------------------------------------------------------------------------
- -- File Name : /monitoring/tablespaces.sql
- -- Author : Maxwell
- -- Description : Displays information about tablespaces.
- -- Requirements : Access to the DBA views.
- -- Call Syntax : @tablespaces
- -- Last Modified: 05-AUG-2022
- -- -----------------------------------------------------------------------------------
-
- SET LINESIZE 200
-
- SELECT tablespace_name,
- block_size,
- extent_management,
- allocation_type,
- segment_space_management,
- status
- FROM dba_tablespaces
- ORDER BY tablespace_name;
- [oracle@MaxwellDBA monitoring]$
