当前位置:首页>开发>正文

oracle数据中怎么查看表空间的名称及大小 oracle 如何查看表空间最大的大小

2023-06-21 12:30:54 互联网 未知 开发

 oracle数据中怎么查看表空间的名称及大小 oracle 如何查看表空间最大的大小

oracle数据中怎么查看表空间的名称及大小?

可用如下语句:
select b.file_name 物理文件名,b.tablespace_name 表空间,b.bytes / 1024 / 1024 大小M,(b.bytes - sum(nvl(a.bytes, 0))) / 1024 / 1024 已使用M,
substr((b.bytes - sum(nvl(a.bytes, 0))) / (b.bytes) * 100, 1, 5) 利用率   
from dba_free_space a,dba_data_files b   
where a.file_id = b.file_id
group by b.tablespace_name,b.file_name, b.bytes   
order by b.tablespace_name查询结果:


解读:

该语句通过查询dba_free_space,dba_data_files,dba_tablespaces这三个数据字典表,得到了表空间名称,表空间类型,区管理类型,以”兆”为单位的表空间大小,已使用的表空间大小及表空间利用率。dba_free_space表描述了表空间的空闲大小,dba_data_files表描述了数据库中的数据文件,dba_tablespaces表描述了数据库中的表空间。
上面语句中from子句后有三个select语句,每个select语句相当于一个视图,视图的名称分别为a、b、c,通过它们之间的关联关系,我们得到了表空间的相关信息。

oracle 如何查看表空间最大的大小

select tablespace_name,sum(maxbytes)/1024/1024/1024 from dba_data_files where tablespace_name=XXXXXX(大写,或者用upper)
如果要查看所有表空间的,那么就用group by分组解决。

oracle怎么查询表对应的表空间


1、select TABLE_NAME,DEF_TABLESPACE_NAME from USER_PART_TABLES order by DEF_TABLESPACE_NAME
2、col SEGMENT_NAME format a30
select distinct SEGMENT_NAME,TABLESPACE_NAME from dba_segments where TABLESPACE_NAME=‘TS1’ order by SEGMENT_NAME
3、 select TABLE_NAME,TABLESPACE_NAME from user_tables order by table_name

oracle中如何查看一个表所占空间的大小,用一条sql

每张表都是作为“段”来存储的,可以通过user_segments视图查看其相应信息,例:
SELECT segment_name AS TABLENAME,BYTES B,BYTES/1024 KB,BYTES/1024/1024 MB FROM user_segments WHERE segment_name=EP_SC106

Oracle怎么查看表的大小?

有两种含义的表大小。一种是分配给一个表的物理空间数量,而不管空间是否被使用。可以这样查询获得字节数:

select segment_name, bytes 
from user_segments 
where segment_type = TABLE 
或者
Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name

另一种表实际使用的空间。这样查询:

analyze table emp compute statistics 
select num_rows * avg_row_len 
from user_tables 
where table_name = EMP

查看每个表空间的大小
Select Tablespace_Name,Sum(bytes)/1024/1024 From Dba_Segments Group By Tablespace_Name

oracle如何查看用户的表空间大小?

select t.tablespace_name,
round(t.bytes / 1024 / 1024 / 1024, 2) || G "总大小",
round((t.bytes - f.bytes) / 1024 / 1024 / 1024, 2) || G "已使用",
round(100 * (t.bytes - f.bytes) / t.bytes, 2) || % "使用率"
from (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) t,
(select tablespace_name, sum(bytes) bytes
from dba_free_space
group by tablespace_name) f
where f.tablespace_name( ) = t.tablespace_name

oracle中如何查看一个表所占空间的大小, 这张表包含blob字段

写了一个,你试试:
select a.TABLESPACE_NAME "TableSpace Name",
round(a.BYTES / 1024 / 1024) "MB Allocated",
round((a.BYTES-nvl(b.BYTES, 0)) / 1024 / 1024) "MB Used",
nvl(round(b.BYTES / 1024 / 1024), 0) "MB Free",
round(((a.BYTES-nvl(b.BYTES, 0))/a.BYTES)*100,2) "Pct Used"
from (select TABLESPACE_NAME,
sum(BYTES) BYTES
from sys.dba_data_files
group by TABLESPACE_NAME) a,
(select TABLESPACE_NAME,
sum(BYTES) BYTES
from sys.dba_free_space
group by TABLESPACE_NAME) b
where a.TABLESPACE_NAME = b.TABLESPACE_NAME ( )
And a.tablespace_name in (表空间名,表空间名,表空间名)

如何在Oracle中查看各个表,表空间占用空间的大小

在Oracle中查看各表及表空间占用空间大小可用sql语句执行查看。
Oracle版本:Oracle 10g
一、查看表占用空间大小语句:
select t.segment_name, t.segment_type, sum(t.bytes / 1024 / 1024) "占用空间(M)"from dba_segments twhere t.segment_type=TABLEgroup by OWNER, t.segment_name, t.segment_type查询结果:

二、查看表空间占用空间大小语句:
select a.tablespace_name,a.bytes/1024/1024 "Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used" from (select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a, (select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b where a.tablespace_name=b.tablespace_name order by ((a.bytes-b.bytes)/a.bytes) desc查询结果:

最新文章

随便看看