查看Oracle数据库中表空间信息的命令方法

经过查询数据库系统中的数据字典表(data dictionary tables)获取表空间的相关信息,首先使用客户端工具链接到数据库,这些工具能够是SQLPLUS字符工具、TOAD、PL/SQL等,链接到数据库后执行以下的查询语句: 数据库

select 
a.a1 表空间名称,
c.c2 类型,
c.c3 区管理,
b.b2
/1024/1024 表空间大小M,
(b.b2
-a.a2)/1024/1024 已使用M,
substr((b.b2
-a.a2)/b.b2*100,1,5) 利用率
from 
(
select  tablespace_name a1, sum(nvl(bytes,0)) a2 from dba_free_space group by tablespace_name) a,
(
select tablespace_name b1,sum(bytes) b2 from dba_data_files group by tablespace_name) b,
(
select tablespace_name c1,contents c2,extent_management c3  from dba_tablespaces) c
where a.a1=b.b1 and c.c1=b.b1;
oracle

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

查看Oracle数据库中数据文件信息的命令方法
经过查询数据库系统中的数据字典表(data dictionary tables)获取数据文件的相关信息,首先使用客户端工具链接到数据库,这些工具能够是SQLPLUS字符工具、TOAD、PL/SQL等,链接到数据库后执行以下的查询语句 spa

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
排序

查看临时表空间和数据库文件的方法
在oracle数据库中,临时表空间主要用于用户在使用order by 、group by语句进行排序和汇总时所需的临时工做空间。要查询数据库中临时表空间的名称,大小及数据文件,能够查询数据字典dba_tablespaces及dba_data_files。命令以下:
io

select 
a.tablespace_name 表空间名称,
b.bytes  大小bytes,
b.
file_name  数据文件名
from dba_tablespaces a, dba_data_files b
Where a.tablespace_name=b.tablespace_name and a.contents='TEMPORARY'; table

从oracle 9i开始,能够建立Temporary tablespace类表空间,即“临时“表空间,这类表空间使用临时文件。临时文件的信息被存储在数据字典V$tempfile中。命令以下:  Select   file #,status,name   from V$tempfile;
相关文章
相关标签/搜索