• 灵活好用的sql monitoring 脚本 part4


    33.Script: column_defaults.sql

    -- Description  : Displays the default values where present for the specified table.

    1. [oracle@MaxwellDBA monitoring]$ cat column_defaults.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/column_defaults.sql
    4. -- Author : Maxwell
    5. -- Description : Displays the default values where present for the specified table.
    6. -- Call Syntax : @column_defaults (table-name)
    7. -- Last Modified: 06-AUG-2022
    8. -- -----------------------------------------------------------------------------------
    9. SET LINESIZE 100
    10. SET VERIFY OFF
    11. SELECT a.column_name "Column",
    12. a.data_default "Default"
    13. FROM all_tab_columns a
    14. WHERE a.table_name = Upper('&1')
    15. AND a.data_default IS NOT NULL
    16. /
    17. [oracle@MaxwellDBA monitoring]$ pwd
    18. /home/oracle/oracledba/monitoring
    19. [oracle@MaxwellDBA monitoring]$

    34.Script: controlfiles.sql

    -- Description  : Displays information about controlfiles.

    1. [oracle@MaxwellDBA monitoring]$ cat controlfiles.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/controlfiles.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information about controlfiles.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @controlfiles
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 100
    11. COLUMN name FORMAT A80
    12. SELECT name,
    13. status
    14. FROM v$controlfile
    15. ORDER BY name;
    16. SET LINESIZE 80
    17. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/controlfiles.sql
    2. NAME STATUS
    3. -------------------------------------------------------------------------------- -------
    4. /opt/oracle/oradata/ORCLCDB/control01.ctl
    5. /opt/oracle/oradata/ORCLCDB/control02.ctl
    6. SQL>

    35.Script: datafiles.sql

    -- Description  : Displays information about datafiles.

    1. [oracle@MaxwellDBA monitoring]$ cat datafiles.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/datafiles.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information about datafiles.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @datafiles
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 200
    11. COLUMN file_name FORMAT A70
    12. SELECT file_id,
    13. file_name,
    14. ROUND(bytes/1024/1024/1024) AS size_gb,
    15. ROUND(maxbytes/1024/1024/1024) AS max_size_gb,
    16. autoextensible,
    17. increment_by,
    18. status
    19. FROM dba_data_files
    20. ORDER BY file_name;
    21. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/datafiles.sql
    2. FILE_ID FILE_NAME SIZE_GB MAX_SIZE_GB AUT INCREMENT_BY STATUS
    3. ---------- ---------------------------------------------------------------------- ---------- ----------- --- ------------ ---------
    4. 3 /opt/oracle/oradata/ORCLCDB/sysaux01.dbf 1 32 YES 1280 AVAILABLE
    5. 1 /opt/oracle/oradata/ORCLCDB/system01.dbf 1 32 YES 1280 AVAILABLE
    6. 4 /opt/oracle/oradata/ORCLCDB/undotbs01.dbf 0 32 YES 640 AVAILABLE
    7. 7 /opt/oracle/oradata/ORCLCDB/users01.dbf 0 32 YES 160 AVAILABLE
    8. SQL>

    36.Script: open_cursors.sql

    -- Description  : Displays a list of all cursors currently open.

    1. [oracle@MaxwellDBA monitoring]$ cat open_cursors.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/open_cursors.sql
    4. -- Author : Maxwell
    5. -- Description : Displays a list of all cursors currently open.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @open_cursors
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SELECT a.user_name,
    11. a.sid,
    12. a.sql_text
    13. FROM v$open_cursor a
    14. ORDER BY 1,2
    15. /
    16. [oracle@MaxwellDBA monitoring]$

    37.Script: open_cursors_by_sid.sql

    -- Description  : Displays the SQL statement held for a specific SID.

    1. [oracle@MaxwellDBA monitoring]$ cat open_cursors_by_sid.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/open_cursors_by_sid.sql
    4. -- Author : Maxwell
    5. -- Description : Displays the SQL statement held for a specific SID.
    6. -- Comments : The SID can be found by running session.sql or top_session.sql.
    7. -- Requirements : Access to the V$ views.
    8. -- Call Syntax : @open_cursors_by_sid (sid)
    9. -- Last Modified: 05-AUG-2022
    10. -- -----------------------------------------------------------------------------------
    11. SET LINESIZE 500
    12. SET PAGESIZE 1000
    13. SET VERIFY OFF
    14. SELECT oc.sql_text, cursor_type
    15. FROM v$open_cursor oc
    16. WHERE oc.sid = &1
    17. ORDER BY cursor_type;
    18. PROMPT
    19. SET PAGESIZE 14
    20. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/open_cursors_by_sid.sql 11
    2. SQL_TEXT CURSOR_TYPE
    3. ------------------------------------------------------------ ----------------------------------------------------------------
    4. insert into smon_scn_time (thread, time_mp, time_dp, scn, sc SESSION CURSOR CACHED
    5. delete from smon_scn_time where scn = (select min(scn) from SESSION CURSOR CACHED
    6. select f.file#, f.block#, f.ts#, f.length from fet$ f, ts$ t SESSION CURSOR CACHED
    7. update smon_scn_time set time_mp=:1, time_dp=:2, scn=:3, scn SESSION CURSOR CACHED
    8. select max(RETENTION) from SYS_FBA_FA SESSION CURSOR CACHED
    9. SQL>

    38.Script: open_cursors_full_by_sid.sql

    -- Description  : Displays the SQL statement held for a specific SID.

    1. [oracle@MaxwellDBA monitoring]$ cat open_cursors_full_by_sid.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/open_cursors_full_by_sid.sql
    4. -- Author : Maxwell
    5. -- Description : Displays the SQL statement held for a specific SID.
    6. -- Comments : The SID can be found by running session.sql or top_session.sql.
    7. -- Requirements : Access to the V$ views.
    8. -- Call Syntax : @open_cursors_full_by_sid (sid)
    9. -- Last Modified: 05-AUG-2022
    10. -- -----------------------------------------------------------------------------------
    11. SET LINESIZE 500
    12. SET PAGESIZE 1000
    13. SET VERIFY OFF
    14. SELECT st.sql_text
    15. FROM v$sqltext st,
    16. v$open_cursor oc
    17. WHERE st.address = oc.address
    18. AND st.hash_value = oc.hash_value
    19. AND oc.sid = &1
    20. ORDER BY st.address, st.piece;
    21. PROMPT
    22. SET PAGESIZE 14
    23. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/open_cursors_full_by_sid.sql 11
    2. SQL_TEXT
    3. ----------------------------------------------------------------
    4. select f.file#, f.block#, f.ts#, f.length from fet$ f, ts$ t whe
    5. re t.ts#=f.ts# and t.dflextpct!=0 and t.bitmapped=0
    6. select max(RETENTION) from SYS_FBA_FA
    7. update smon_scn_time set time_mp=:1, time_dp=:2, scn=:3, scn_wrp
    8. =:4, scn_bas=:5, num_mappings=:6, tim_scn_map=:7 where scn = (
    9. select min(scn) from smon_scn_time)
    10. delete from smon_scn_time where scn = (select min(scn) from smo
    11. n_scn_time)
    12. insert into smon_scn_time (thread, time_mp, time_dp, scn, scn_wr
    13. p, scn_bas, num_mappings, tim_scn_map) values (0, :1, :2, :3, :4
    14. , :5, :6, :7)
    15. 11 rows selected.
    16. SQL>

    39.Script: options.sql

    -- Description  : Displays information about all database options.

    1. [oracle@MaxwellDBA monitoring]$ cat options.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/options.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information about all database options.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @options
    8. -- Last Modified: 05-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. COLUMN value FORMAT A20
    11. SELECT *
    12. FROM v$option
    13. ORDER BY parameter;
    14. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/options.sql
    2. PARAMETER VALUE CON_ID
    3. ---------------------------------------------------------------- -------------------- ----------
    4. ASM Proxy Instance FALSE 0
    5. Active Data Guard TRUE 0
    6. Adaptive Execution Plans TRUE 0
    7. Advanced Analytics TRUE 0
    8. Advanced Compression TRUE 0
    9. Advanced Index Compression TRUE 0
    10. Advanced replication TRUE 0
    11. Application Role TRUE 0
    12. Automatic Data Optimization TRUE 0
    13. Automatic Storage Management FALSE 0
    14. Backup Encryption TRUE 0
    15. PARAMETER VALUE CON_ID
    16. ---------------------------------------------------------------- -------------------- ----------
    17. Basic Compression TRUE 0
    18. Bit-mapped indexes TRUE 0
    19. Block Change Tracking TRUE 0
    20. Block Media Recovery TRUE 0
    21. Cache Fusion Lock Accelerator TRUE 0
    22. Centrally Managed User TRUE 0
    23. Change Data Capture TRUE 0
    24. Coalesce Index TRUE 0
    25. Connection multiplexing TRUE 0
    26. Connection pooling TRUE 0
    27. Cross Transportable Backups TRUE 0
    28. PARAMETER VALUE CON_ID
    29. ---------------------------------------------------------------- -------------------- ----------
    30. DICOM TRUE 0
    31. Data Mining TRUE 0
    32. Data Redaction TRUE 0
    33. Database queuing TRUE 0
    34. Database resource manager TRUE 0
    35. Deferred Segment Creation TRUE 0
    36. Duplexed backups TRUE 0
    37. Enterprise User Security TRUE 0
    38. Exadata Discovery TRUE 0
    39. Export transportable tablespaces TRUE 0
    40. Fast-Start Fault Recovery TRUE 0
    41. PARAMETER VALUE CON_ID
    42. ---------------------------------------------------------------- -------------------- ----------
    43. File Mapping TRUE 0
    44. Fine-grained Auditing TRUE 0
    45. Fine-grained access control TRUE 0
    46. Flashback Data Archive TRUE 0
    47. Flashback Database TRUE 0
    48. Flashback Table TRUE 0
    49. Global Data Services TRUE 0
    50. Heat Map TRUE 0
    51. I/O Server FALSE 0
    52. In-Memory Aggregation TRUE 0
    53. In-Memory Column Store TRUE 0
    54. PARAMETER VALUE CON_ID
    55. ---------------------------------------------------------------- -------------------- ----------
    56. Incremental backup and recovery TRUE 0
    57. Instead-of triggers TRUE 0
    58. Java TRUE 0
    59. Join index TRUE 0
    60. Managed Standby TRUE 0
    61. Management Database FALSE 0
    62. Materialized view rewrite TRUE 0
    63. OLAP TRUE 0
    64. OLAP Window Functions TRUE 0
    65. Objects TRUE 0
    66. Online Index Build TRUE 0
    67. PARAMETER VALUE CON_ID
    68. ---------------------------------------------------------------- -------------------- ----------
    69. Online Redefinition TRUE 0
    70. Oracle Data Guard TRUE 0
    71. Oracle Database Vault FALSE 0
    72. Oracle Label Security FALSE 0
    73. Parallel backup and recovery TRUE 0
    74. Parallel execution TRUE 0
    75. Parallel load TRUE 0
    76. Partitioning TRUE 0
    77. Plan Stability TRUE 0
    78. Point-in-time tablespace recovery TRUE 0
    79. Privilege Analysis TRUE 0
    80. PARAMETER VALUE CON_ID
    81. ---------------------------------------------------------------- -------------------- ----------
    82. Proxy authentication/authorization TRUE 0
    83. Real Application Clusters FALSE 0
    84. Real Application Security TRUE 0
    85. Real Application Testing TRUE 0
    86. Result Cache TRUE 0
    87. SQL Plan Management TRUE 0
    88. Sample Scan TRUE 0
    89. SecureFiles Encryption TRUE 0
    90. Server Flash Cache TRUE 0
    91. Snapshot time recovery TRUE 0
    92. Spatial TRUE 0
    93. PARAMETER VALUE CON_ID
    94. ---------------------------------------------------------------- -------------------- ----------
    95. Streams Capture TRUE 0
    96. Table Clustering TRUE 0
    97. Transparent Application Failover TRUE 0
    98. Transparent Data Encryption TRUE 0
    99. Transparent Sensitive Data Protection TRUE 0
    100. Trial Recovery TRUE 0
    101. Unified Auditing FALSE 0
    102. Unused Block Compression TRUE 0
    103. XStream TRUE 0
    104. Zone Maps TRUE 0
    105. 87 rows selected.
    106. SQL>

    40.Script: db_cache_advice.sql

    -- Description  : Predicts how changes to the buffer cache will affect physical reads.

    1. [oracle@MaxwellDBA monitoring]$ cat db_cache_advice.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/db_cache_advice.sql
    4. -- Author : Maxwell
    5. -- Description : Predicts how changes to the buffer cache will affect physical reads.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @db_cache_advice
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. COLUMN size_for_estimate FORMAT 999,999,999,999 heading 'Cache Size (MB)'
    11. COLUMN buffers_for_estimate FORMAT 999,999,999 heading 'Buffers'
    12. COLUMN estd_physical_read_factor FORMAT 999.90 heading 'Estd Phys|Read Factor'
    13. COLUMN estd_physical_reads FORMAT 999,999,999,999 heading 'Estd Phys| Reads'
    14. SELECT size_for_estimate,
    15. buffers_for_estimate,
    16. estd_physical_read_factor,
    17. estd_physical_reads
    18. FROM v$db_cache_advice
    19. WHERE name = 'DEFAULT'
    20. AND block_size = (SELECT value
    21. FROM v$parameter
    22. WHERE name = 'db_block_size')
    23. AND advice_status = 'ON';
    24. [oracle@MaxwellDBA monitoring]$

    41.Script: db_info.sql

    -- Description  : Displays general information about the database.

    1. [oracle@MaxwellDBA monitoring]$ cat db_info.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/db_info.sql
    4. -- Author : Maxwell
    5. -- Description : Displays general information about the database.
    6. -- Requirements : Access to the v$ views.
    7. -- Call Syntax : @db_info
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET PAGESIZE 1000
    11. SET LINESIZE 100
    12. SET FEEDBACK OFF
    13. SELECT *
    14. FROM v$database;
    15. SELECT *
    16. FROM v$instance;
    17. SELECT *
    18. FROM v$version;
    19. SELECT a.name,
    20. a.value
    21. FROM v$sga a;
    22. SELECT Substr(c.name,1,60) "Controlfile",
    23. NVL(c.status,'UNKNOWN') "Status"
    24. FROM v$controlfile c
    25. ORDER BY 1;
    26. SELECT Substr(d.name,1,60) "Datafile",
    27. NVL(d.status,'UNKNOWN') "Status",
    28. d.enabled "Enabled",
    29. LPad(To_Char(Round(d.bytes/1024000,2),'9999990.00'),10,' ') "Size (M)"
    30. FROM v$datafile d
    31. ORDER BY 1;
    32. SELECT l.group# "Group",
    33. Substr(l.member,1,60) "Logfile",
    34. NVL(l.status,'UNKNOWN') "Status"
    35. FROM v$logfile l
    36. ORDER BY 1,2;
    37. PROMPT
    38. SET PAGESIZE 14
    39. SET FEEDBACK ON
    40. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/db_info.sql
    2. DBID NAME
    3. ---------- --------------------------------------------------------------------------------
    4. CREATED RESETLOGS_CHANGE# RESETLOGS_TIME PRIOR_RESETLOGS_CHANGE# PRIOR_RESETLOGS_TI
    5. ------------------ ----------------- ------------------ ----------------------- ------------------
    6. LOG_MODE CHECKPOINT_CHANGE# ARCHIVE_CHANGE# CONTROL CONTROLFILE_CREATE CONTROLFILE_SEQUENCE#
    7. ------------ ------------------ --------------- ------- ------------------ ---------------------
    8. CONTROLFILE_CHANGE# CONTROLFILE_TIME OPEN_RESETL VERSION_TIME OPEN_MODE
    9. ------------------- ------------------ ----------- ------------------ --------------------
    10. PROTECTION_MODE PROTECTION_LEVEL REMOTE_A ACTIVATION# SWITCHOVER# DATABASE_ROLE
    11. -------------------- -------------------- -------- ----------- ----------- ----------------
    12. ARCHIVELOG_CHANGE# ARCHIVEL SWITCHOVER_STATUS DATAGUAR GUARD_S SUPPLEME SUP SUP
    13. ------------------ -------- -------------------- -------- ------- -------- --- ---
    14. FORCE_LOGGING PLATFORM_ID
    15. --------------------------------------- -----------
    16. PLATFORM_NAME
    17. ----------------------------------------------------------------------------------------------------
    18. RECOVERY_TARGET_INCARNATION# LAST_OPEN_INCARNATION# CURRENT_SCN FLASHBACK_ON SUP SUP
    19. ---------------------------- ---------------------- ----------- ------------------ --- ---
    20. DB_UNIQUE_NAME STANDBY_BECAME_PRIMARY_SCN FS_FAILOVER_MODE FS_FAILOVER_STATUS
    21. ------------------------------ -------------------------- ------------------- ----------------------
    22. FS_FAILOVER_CURRENT_TARGET FS_FAILOVER_THRESHOLD FS_FAIL
    23. ------------------------------ --------------------- -------
    24. FS_FAILOVER_OBSERVER_HOST
    25. ----------------------------------------------------------------------------------------------------
    26. CON PRIMARY_DB_UNIQUE_NAME SUP MIN_REQUIRED_CAPTURE_CHANGE# CDB CON_ID
    27. --- ------------------------------ --- ---------------------------- --- ----------
    28. PENDING_ROLE_CHANGE_TASKS
    29. ----------------------------------------------------------------------------------------------------
    30. CON_DBID FOR SUP
    31. ---------- --- ---
    32. 2879679614 ORCLCDB
    33. 29-JUN-22 1920977 29-JUN-22 1 17-APR-19
    34. NOARCHIVELOG 6561295 6443856 CURRENT 29-JUN-22 115474
    35. 6606029 06-AUG-22 NOT ALLOWED 29-JUN-22 READ WRITE
    36. MAXIMUM PERFORMANCE UNPROTECTED ENABLED 2879716734 2879716734 PRIMARY
    37. 0 DISABLED NOT ALLOWED DISABLED NONE NO NO NO
    38. NO 13
    39. Linux x86 64-bit
    40. 2 2 6606060 NO NO NO
    41. ORCLCDB 0 DISABLED DISABLED
    42. 0
    43. NO NO YES 0
    44. NOT APPLICABLE
    45. 2879679614 NO NO
    46. INSTANCE_NUMBER INSTANCE_NAME HOST_NAME
    47. --------------- ---------------- ----------------------------------------------------------------
    48. VERSION VERSION_LEGACY VERSION_FULL STARTUP_TIME STATUS PAR THREAD#
    49. ----------------- ----------------- ----------------- ------------------ ------------ --- ----------
    50. ARCHIVE LOG_SWITCH_WAIT LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST BLO CON_ID
    51. ------- --------------- ---------- --- ----------------- ------------------ --------- --- ----------
    52. INSTANCE_MO EDITION FAMILY
    53. ----------- ------- --------------------------------------------------------------------------------
    54. DATABASE_TYPE
    55. ---------------
    56. 1 ORCLCDB MaxwellDBA
    57. 19.0.0.0.0 19.0.0.0.0 19.3.0.0.0 29-JUN-22 OPEN NO 1
    58. STOPPED ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL NO 0
    59. REGULAR EE
    60. SINGLE
    61. BANNER
    62. --------------------------------------------------------------------------------
    63. BANNER_FULL
    64. ----------------------------------------------------------------------------------------------------
    65. BANNER_LEGACY CON_ID
    66. -------------------------------------------------------------------------------- ----------
    67. Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    68. Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
    69. Version 19.3.0.0.0
    70. Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production 0
    71. NAME VALUE
    72. -------------------------------------------------------------------------------- ----------
    73. Fixed Size ##########
    74. Variable Size ##########
    75. Database Buffers ##########
    76. Redo Buffers ##########
    77. Controlfile
    78. ----------------------------------------------------------------------------------------------------
    79. Status
    80. -------
    81. /opt/oracle/oradata/ORCLCDB/control01.ctl
    82. UNKNOWN
    83. /opt/oracle/oradata/ORCLCDB/control02.ctl
    84. UNKNOWN
    85. Datafile
    86. ----------------------------------------------------------------------------------------------------
    87. Status Enabled Size (M)
    88. ------- ---------- ----------------------------------------
    89. /opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf
    90. ONLINE READ WRITE 399.3
    91. /opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf
    92. SYSTEM READ WRITE 286.7
    93. /opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf
    94. ONLINE READ WRITE 102.4
    95. /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
    96. ONLINE READ WRITE 5.1
    97. /opt/oracle/oradata/ORCLCDB/pdbseed/sysaux01.dbf
    98. ONLINE READ WRITE 337.9
    99. /opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf
    100. SYSTEM READ WRITE 276.4
    101. /opt/oracle/oradata/ORCLCDB/pdbseed/undotbs01.dbf
    102. ONLINE READ WRITE 102.4
    103. /opt/oracle/oradata/ORCLCDB/sysaux01.dbf
    104. ONLINE READ WRITE 1310.7
    105. /opt/oracle/oradata/ORCLCDB/system01.dbf
    106. SYSTEM READ WRITE 962.5
    107. /opt/oracle/oradata/ORCLCDB/undotbs01.dbf
    108. ONLINE READ WRITE 302.0
    109. /opt/oracle/oradata/ORCLCDB/users01.dbf
    110. ONLINE READ WRITE 5.1
    111. Group
    112. ----------
    113. Logfile
    114. ----------------------------------------------------------------------------------------------------
    115. Status
    116. -------
    117. 1
    118. /opt/oracle/oradata/ORCLCDB/redo01.log
    119. UNKNOWN
    120. 2
    121. /opt/oracle/oradata/ORCLCDB/redo02.log
    122. UNKNOWN
    123. 3
    124. /opt/oracle/oradata/ORCLCDB/redo03.log
    125. UNKNOWN
    126. SQL>

    42.Script: db_links.sql

    -- Description  : Displays information on all database links.

    1. [oracle@MaxwellDBA monitoring]$ cat db_links.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/db_links.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information on all database links.
    6. -- Requirements : Access to the DBA views.
    7. -- Call Syntax : @db_links
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 150
    11. COLUMN owner FORMAT A30
    12. COLUMN db_link FORMAT A30
    13. COLUMN username FORMAT A30
    14. COLUMN host FORMAT A30
    15. SELECT owner,
    16. db_link,
    17. username,
    18. host
    19. FROM dba_db_links
    20. ORDER BY owner, db_link;
    21. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/db_links.sql
    2. OWNER DB_LINK USERNAME HOST
    3. ------------------------------ ------------------------------ ------------------------------ ------------------------------
    4. SYS SYS_HUB SEEDDATA
    5. 1 row selected.
    6. SQL>

    43.Script: db_links_open.sql

    -- Description  : Displays information on all open database links.

    1. [oracle@MaxwellDBA monitoring]$ cat db_links_open.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/db_links_open.sql
    4. -- Author : Maxwell
    5. -- Description : Displays information on all open database links.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @db_links_open
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 200
    11. COLUMN db_link FORMAT A30
    12. SELECT db_link,
    13. owner_id,
    14. logged_on,
    15. heterogeneous,
    16. protocol,
    17. open_cursors,
    18. in_transaction,
    19. update_sent,
    20. commit_point_strength
    21. FROM v$dblink
    22. ORDER BY db_link;
    23. SET LINESIZE 80
    24. [oracle@MaxwellDBA monitoring]$

    44.Script: db_properties.sql

    -- Description  : Displays all database property values.

    1. [oracle@MaxwellDBA monitoring]$ cat db_properties.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/db_properties.sql
    4. -- Author : Maxwell
    5. -- Description : Displays all database property values.
    6. -- Call Syntax : @db_properties
    7. -- Last Modified: 06-AUG-2022
    8. -- -----------------------------------------------------------------------------------
    9. COLUMN property_value FORMAT A50
    10. SELECT property_name,
    11. property_value
    12. FROM database_properties
    13. ORDER BY property_name;
    14. [oracle@MaxwellDBA monitoring]$

    45.Script: param_valid_values.sql

    -- Description  : Lists all valid values for the specified parameter.

    1. [oracle@MaxwellDBA monitoring]$ cat param_valid_values.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/param_valid_values.sql
    4. -- Author : Maxwell
    5. -- Description : Lists all valid values for the specified parameter.
    6. -- Call Syntax : @param_valid_values (parameter-name)
    7. -- Requirements : Access to the v$views.
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET VERIFY OFF
    11. COLUMN value FORMAT A50
    12. COLUMN isdefault FORMAT A10
    13. SELECT value,
    14. isdefault
    15. FROM v$parameter_valid_values
    16. WHERE name = '&1';
    17. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/param_valid_values.sql default_sharing
    2. VALUE ISDEFAULT
    3. -------------------------------------------------- ----------
    4. NONE FALSE
    5. METADATA FALSE
    6. OBJECT FALSE
    7. DATA FALSE
    8. EXTENDED DATA FALSE
    9. 5 rows selected.
    10. SQL>

    46.Script: parameter_diffs.sql

    -- Description  : Displays parameter values that differ between the current value and the spfile.

    1. [oracle@MaxwellDBA monitoring]$ cat parameter_diff.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/parameter_diffs.sql
    4. -- Author : Maxwell
    5. -- Description : Displays parameter values that differ between the current value and the spfile.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @parameter_diffs
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 120
    11. COLUMN name FORMAT A30
    12. COLUMN current_value FORMAT A30
    13. COLUMN sid FORMAT A8
    14. COLUMN spfile_value FORMAT A30
    15. SELECT p.name,
    16. i.instance_name AS sid,
    17. p.value AS current_value,
    18. sp.sid,
    19. sp.value AS spfile_value
    20. FROM v$spparameter sp,
    21. v$parameter p,
    22. v$instance i
    23. WHERE sp.name = p.name
    24. AND sp.value != p.value;
    25. COLUMN FORMAT DEFAULT
    26. [oracle@MaxwellDBA monitoring]$

    47.Script: parameters.sql

    -- Description  : Displays a list of all the parameters.

    1. [oracle@MaxwellDBA monitoring]$ cat parameters.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/parameters.sql
    4. -- Author : Maxwell
    5. -- Description : Displays a list of all the parameters.
    6. -- Requirements : Access to the v$ views.
    7. -- Call Syntax : @parameters
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 500
    11. COLUMN name FORMAT A30
    12. COLUMN value FORMAT A60
    13. SELECT p.name,
    14. p.type,
    15. p.value,
    16. p.isses_modifiable,
    17. p.issys_modifiable,
    18. p.isinstance_modifiable
    19. FROM v$parameter p
    20. ORDER BY p.name;
    21. [oracle@MaxwellDBA monitoring]$

     

    48.Script: parameters_non_default.sql

    -- Description  : Displays a list of all the non-default parameters.

    1. [oracle@MaxwellDBA monitoring]$ cat parameters_non_default.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/parameters_non_default.sql
    4. -- Author : Maxwell
    5. -- Description : Displays a list of all the non-default parameters.
    6. -- Requirements : Access to the v$ views.
    7. -- Call Syntax : @parameters_non_default
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 150
    11. COLUMN name FORMAT A50
    12. COLUMN value FORMAT A50
    13. SELECT name,
    14. value
    15. FROM v$parameter
    16. WHERE isdefault = 'FALSE';
    17. [oracle@MaxwellDBA monitoring]$
    1. SQL> clea scre
    2. SQL> @/home/oracle/oracledba/monitoring/parameters_non_default.sql
    3. NAME VALUE
    4. -------------------------------------------------- --------------------------------------------------
    5. processes 300
    6. nls_language AMERICAN
    7. nls_territory AMERICA
    8. memory_target 1509949440
    9. control_files /opt/oracle/oradata/ORCLCDB/control01.ctl, /opt/or
    10. acle/oradata/ORCLCDB/control02.ctl
    11. db_block_size 8192
    12. compatible 19.0.0
    13. undo_tablespace UNDOTBS1
    14. remote_login_passwordfile EXCLUSIVE
    15. NAME VALUE
    16. -------------------------------------------------- --------------------------------------------------
    17. dispatchers (PROTOCOL=TCP) (SERVICE=ORCLCDBXDB)
    18. local_listener LISTENER_ORCLCDB
    19. audit_file_dest /opt/oracle/admin/ORCLCDB/adump
    20. audit_trail DB
    21. db_name ORCLCDB
    22. open_cursors 300
    23. diagnostic_dest /opt/oracle
    24. enable_pluggable_database TRUE
    25. 17 rows selected.
    26. SQL>

    49.Script: default_tablespace.sql

    -- Description  : Displays the default temporary and permanent tablespaces.

    1. [oracle@MaxwellDBA monitoring]$ cat default_tablespaces.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/default_tablespaces.sql
    4. -- Author : Maxwell
    5. -- Description : Displays the default temporary and permanent tablespaces.
    6. -- Requirements : Access to the DATABASE_PROPERTIES views.
    7. -- Call Syntax : @default_tablespaces
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. COLUMN property_name FORMAT A30
    11. COLUMN property_value FORMAT A30
    12. COLUMN description FORMAT A50
    13. SET LINESIZE 200
    14. SELECT *
    15. FROM database_properties
    16. WHERE property_name like '%TABLESPACE';
    17. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/default_tablespaces.sql
    2. PROPERTY_NAME PROPERTY_VALUE DESCRIPTION
    3. ------------------------------ ------------------------------ --------------------------------------------------
    4. DEFAULT_PERMANENT_TABLESPACE USERS Name of default permanent tablespace
    5. DEFAULT_TEMP_TABLESPACE TEMP Name of default temporary tablespace
    6. 2 rows selected.
    7. SQL>

    50.Script: df_free_space.sql

    -- Description  : Displays free space information about datafiles.

    1. [oracle@MaxwellDBA monitoring]$ cat df_free_space.sql
    2. -- -----------------------------------------------------------------------------------
    3. -- File Name : /monitoring/df_free_space.sql
    4. -- Author : Maxwell
    5. -- Description : Displays free space information about datafiles.
    6. -- Requirements : Access to the V$ views.
    7. -- Call Syntax : @df_free_space.sql
    8. -- Last Modified: 06-AUG-2022
    9. -- -----------------------------------------------------------------------------------
    10. SET LINESIZE 120
    11. COLUMN file_name FORMAT A60
    12. SELECT a.file_name,
    13. ROUND(a.bytes/1024/1024) AS size_mb,
    14. ROUND(a.maxbytes/1024/1024) AS maxsize_mb,
    15. ROUND(b.free_bytes/1024/1024) AS free_mb,
    16. ROUND((a.maxbytes-a.bytes)/1024/1024) AS growth_mb,
    17. 100 - ROUND(((b.free_bytes+a.growth)/a.maxbytes) * 100) AS pct_used
    18. FROM (SELECT file_name,
    19. file_id,
    20. bytes,
    21. GREATEST(bytes,maxbytes) AS maxbytes,
    22. GREATEST(bytes,maxbytes)-bytes AS growth
    23. FROM dba_data_files) a,
    24. (SELeCT file_id,
    25. SUM(bytes) AS free_bytes
    26. FROM dba_free_space
    27. GROUP BY file_id) b
    28. WHERE a.file_id = b.file_id
    29. ORDER BY file_name;
    30. [oracle@MaxwellDBA monitoring]$
    1. SQL> @/home/oracle/oracledba/monitoring/df_free_space.sql
    2. FILE_NAME SIZE_MB MAXSIZE_MB FREE_MB GROWTH_MB PCT_USED
    3. ------------------------------------------------------------ ---------- ---------- ---------- ---------- ----------
    4. /opt/oracle/oradata/ORCLCDB/sysaux01.dbf 1280 32768 106 31488 4
    5. /opt/oracle/oradata/ORCLCDB/system01.dbf 940 32768 7 31828 3
    6. /opt/oracle/oradata/ORCLCDB/undotbs01.dbf 295 32768 281 32473 0
    7. /opt/oracle/oradata/ORCLCDB/users01.dbf 5 32768 2 32763 0
    8. 4 rows selected.
    9. SQL>

  • 相关阅读:
    javascript数据类型
    SCI论文还迟迟动不了笔?2/3区仅1个月25天录用,看看经验之谈
    LeetCode(14)加油站【数组/字符串】【中等】
    Python基于PHP+MySQL的个人网页设计与实现
    python subprocess.cal调用wkhtmltohtml中遇到的问题
    通达信指标编写,16进制颜色对照表,妈妈再也不用担心颜色不够用了!!
    Unity中关于多线程的一些事
    The Seven Tools of Causal Inference with Reflections on Machine Learning 文章解读
    彻底弄懂Vue的作用域插槽
    「学习笔记」AC 自动机
  • 原文地址:https://blog.csdn.net/u011868279/article/details/126188955