"Oracle Series" counts the size of Oracle database archive logs by day

You can use the following SQL query:

select
    to_char(completion_time, 'YYYY-MM-DD') as archivelog_date,
    round(sum(blocks * block_size) / 1024 / 1024 / 1024, 2) as archivelog_size_gb
from
    gv$archived_log
where
    to_char(completion_time, 'YYYY-MM-DD') BETWEEN '开始日期' AND '结束日期'
group by
    to_char(completion_time, 'YYYY-MM-DD')
order by
    to_char(completion_time, 'YYYY-MM-DD');

Replace 'Start Date' and 'End Date' with the date range you want to count, in the format of 'YYYY-MM-DD'.

This query fetches information about archived logs from the view, grouped and summarized based on date Oracle. v$archived_logIt converts the archive log completion time (completion_time) to a date and summarizes the archive log size in G by date.

v$archived_logand gv$archived_logare both views used to query Oracledatabase archive log information, but their RAC - Real Application Clustersusage scenarios in multi-instance ( ) environments are different.

  • v$archived_log( v$Indicates " View")
    1) This is a view used to query archive log information in a single instance database.
    2) When you Oracleare working on a single instance database, you can use this view to view information about archive logs.
    3) This view only displays the archive log information of the currently connected database instance.
  • gv$archived_log( gv$Indicates " Global View")
    1) This is a global view used to query archive log information, usually Oracle RACused in the environment.
    2) In Oracle RAC, multiple database instances can run on different nodes at the same time, sharing the same database. In this case, archived log information may relate to multiple instances.
    3) gv$archived_logArchive log information for all instances can be displayed across multiple instances, allowing you to RACview and manage archive logs across the entire environment.

In short, v$archived_logit is suitable for single-instance databases and gv$archived_logmulti-instance Oracle RACenvironments for viewing and managing archive log information globally. In a single-instance environment, you can use v$archived_log, while in RACan environment it is generally preferred to use gv$archived_logto monitor and analyze archived log data.

Note that to run this query, you need to have appropriate database permissions and be connected to the database instance that contains the archive log information. Also, make sure to replace the date range to get the data you are interested in.

Guess you like

Origin blog.csdn.net/liuhuanping/article/details/133042003