简体   繁体   English

如何检查和计算 oracle 数据库、表空间、模式、对象、回收站等的完整大小?

[英]How to check and calculate the complete size of oracle database, tablespaces, schemas, objects, recycle bin and more?

This question answer is already available in segments over the internet with a more informative title.这个问题的答案已经在互联网上以更丰富的标题提供。 Aspirants mostly looking for a different type of size accumulation:有抱负的人主要寻找不同类型的尺寸积累:

  • Complete Size of Database on a physical disk.物理磁盘上数据库的完整大小。
  • Actual space used by complete DB, all schemas, specific user, objects, and quota space.完整数据库、所有模式、特定用户、对象和配额空间使用的实际空间。
  • Space occupied by dba_recyclebin for all DB and users dba_recyclebin 为所有 DB 和用户占用的空间
  • Size of physical and temporary tablespace with calculated details具有计算详细信息的物理和临时表空间的大小

And we will keep on update this Solution for more helpful, thank!我们将继续更新此解决方案以获得更多帮助,谢谢!

Here are a useful set of SQL statements:以下是一组有用的 SQL 语句:

# Complete Size of Database on a physical disk (unless you are using ASM). # 物理磁盘上数据库的完整大小(除非您使用 ASM)。

select sum(bytes / (1024*1024)) "DB Size in MB" from dba_data_files;
select sum(bytes / (1024*1024*1024)) "Size in GB" from dba_data_files;
select sum(bytes / (1024*1024*1024)) "Size in GB" from dba_temp_files;
select (select sum(bytes)/1024/1024/1024 from dba_data_files) + (select sum(bytes)/1024/1024/1024 from dba_temp_files) "Size in GB" from dual;

# Actual space used by complete DB, all schemas, specific user, objects and quota space. # 完整数据库、所有模式、特定用户、对象和配额空间使用的实际空间。

select sum(bytes)/1024/1024/1024 "Size in GB" from dba_segments;
select owner, sum(bytes)/1024/1024 "Size in MB" from dba_segments group  by owner;
select owner, sum(bytes)/1024/1024 "Size in MB" from dba_segments where owner='SYSMAN' group  by owner;
select segment_name, segment_type, bytes/1024/1024 "Size in MB" from dba_segments where segment_type='MATERIALIZED VIEW' and segment_name='MPC_TIME_WRITING_ALL_MV';
--Size quota space
select username, tablespace_name, sum(bytes)/1024/1024 "Size in MB" from dba_ts_quotas where username in ('SYSMAN') group by username, tablespace_name;

# Space occupied by dba_recyclebin for all DB and users # dba_recyclebin 为所有 DB 和用户占用的空间

--Fyi,  SHOW PARAMETERS db_block_size
--      1 block = 512 bytes         
select owner, type, count(*) from dba_recyclebin group by owner, type;  
select owner, (sum(space)*512)/1024/1024 "Size in MB" from dba_recyclebin group by owner order by sum(space);
select owner, (sum(space)*512)/1024/1024 "Size in MB" from dba_recyclebin where owner='SYSMAN' group by owner order by sum(space);

# Size of physical and temporary tablespace with calculated details # 带有计算细节的物理和临时表空间的大小

--Physical tablespace
SELECT tablespace_name, SUM(bytes)/1024/1024 "Used in MB", SUM(maxbytes)/1024/1024 "Max in MB" FROM dba_data_files GROUP BY tablespace_name;
SELECT tablespace_name, SUM(bytes)/1024/1024 "Used in MB", SUM(maxbytes)/1024/1024 "Max in MB" FROM dba_data_files WHERE tablespace_name='SYSAUX' GROUP BY tablespace_name;

--Temporary tablespace
SELECT tablespace_name, SUM(bytes)/1024/1024 "Used in MB", SUM(maxbytes)/1024/1024 "Max in MB" FROM dba_temp_files GROUP BY tablespace_name;
SELECT tablespace_name, SUM(bytes)/1024/1024 "Used in MB", SUM(maxbytes)/1024/1024 "Max in MB" FROM dba_temp_files WHERE tablespace_name='SYS_TEMP' GROUP BY tablespace_name;

--Calculated details
SELECT df.tablespace_name TABLESPACE, df.total_space TOTAL_SPACE,
fs.free_space FREE_SPACE, df.total_space_mb TOTAL_SPACE_MB,
(df.total_space_mb - fs.free_space_mb) USED_SPACE_MB,
fs.free_space_mb FREE_SPACE_MB,
ROUND(100 * (fs.free_space / df.total_space),2) PCT_FREE
FROM (SELECT tablespace_name, SUM(bytes) TOTAL_SPACE,
   ROUND(SUM(bytes) / 1048576) TOTAL_SPACE_MB
   FROM dba_data_files
   GROUP BY tablespace_name) df,
  (SELECT tablespace_name, SUM(bytes) FREE_SPACE,
    ROUND(SUM(bytes) / 1048576) FREE_SPACE_MB
    FROM dba_free_space
    GROUP BY tablespace_name) fs
WHERE df.tablespace_name = fs.tablespace_name(+)
ORDER BY fs.tablespace_name;

The above list of SQL statements are gist to help you achieve your result, You may alter them as per your requirement.上面的 SQL 语句列表是帮助您实现结果的要点,您可以根据需要更改它们。

Thanks!谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不导入的情况下从 .dmp 文件列出 Oracle 中的所有模式和表空间? - How to list all schemas and tablespaces in Oracle from .dmp file without importing? Oracle:验证对象是否属于其表空间的脚本 - Oracle: Script to verify that objects belong to their tablespaces 我们如何在oracle中找到相同数据库实例的两个模式之间的对象差异 - How we can find difference in objects between two schemas of same database instance in oracle 如何获取Oracle中一个表所属的所有表空间? - How to get all tablespaces that a table belongs to in Oracle? 如何使用ASMM检查oracle数据库中的即时缓冲区缓存大小? - How to check instant buffer cache size in oracle database with ASMM? 在oracle中检查架构表空间使用情况 - Check schemas tablespace usage in oracle 默认模式的SQL文件在哪里(Oracle数据库) - Where are the sql files of the default schemas (Oracle database) 如何检查分配给Schema,oracle数据库中的角色的对象的特权(DDL,DML,DCL)? - How to check the privileges (DDL,DML,DCL) on objects assigned to Schema, Roles in oracle Database? 我可以在 SQL Server 数据库实例和 Oracle 中使用多少个架构(限制)? - How many schemas (Limit) can I use in an instance of a SQL Server database and in Oracle? 如何在Oracle数据库中小写对象? - How to lower case objects in Oracle database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM