当前位置:首页>正文

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

2023-04-14 14:15:18 互联网 未知

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
b.file_id 文件ID号,
b.tablespace_name 表空间名,
b.bytes/1024/1024||M字节数,
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024||M 已使用,
sum(nvl(a.bytes,0))/1024/1024||M 剩余空间,
100 - sum(nvl(a.bytes,0))/(b.bytes)*100 占用百分比
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_id,b.bytes
order by b.file_id
备注:建议用系统管理员dba权限进行查看。

怎么察看Oracle 数据库表空间的使用情况

查看的方法和详细的操作步骤如下:
1、首先,因为oracle在Linux系统下运行,所以必须连接到Linux系统,如下图所示,然后进入下一步。

2、其次,完成上述步骤后,连接成功,进入Oracle控制台。
 输入命令“sqlplus / as sysdba”,如下图所示,然后进入下一步。

3、接着,完成上述步骤后,在sql命令行上,输入以下代码,如下图所示,然后进入下一步。

4、最后,完成上述步骤后,就可以查看相应的结果了,如下图所示。这样,问题就解决了。

如何查看oracle表空间大小的使用情况

1. 查看所有表空间大小

SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_data_files
2 group by tablespace_name

2. 已经使用的表空间大小
SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_free_space
2 group by tablespace_name

3. 所以使用空间可以这样计算

select a.tablespace_name,total,free,total-free used from
( select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files
group by tablespace_name) a,
( select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space
group by tablespace_name) b
where a.tablespace_name=b.tablespace_name

4. 下面这条语句查看所有segment的大小。
Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name

5. 还有在命令行情况下如何将结果放到一个文件里。
SQL> spool out.txt
SQL> select * from v$database
SQL> spool off

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

1、看各种参数大小预设值
SQL> show parameter size
2、看有哪些表空间
SQL> col file_NAME format a60
SQL> col TABLESPACE_NAME format a30
SQL> select TABLESPACE_NAME,FILE_NAME from dba_data_files order by TABLESPACE_NAME
3、看表空间使用情况及最大容量
select sum(bytes)/1024/1024 size_mb,sum(MAXBYTES)/1024/1024 max from dba_data_files where tablespace_name=USERS

SIZE_MB MAX
---------- ----------
2376.25 32767.9844

oracle中查询某个库中所有的表以及所占的表空间大小,求给sql

查某一用户下的表
select SEGMENT_NAME,TABLESPACE_NAME,sum(BYTES/1024/1024)||M  from USER_extents where SEGMENT_TYPE=TABLE
group by SEGMENT_NAME,TABLESPACE_NAME
查所有的表
select SEGMENT_NAME,TABLESPACE_NAME,sum(BYTES/1024/1024)||M  from dba_extents where SEGMENT_TYPE=TABLE
group by SEGMENT_NAME,TABLESPACE_NAME

如何在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查询结果: