这个方法很多吧,可以使用语句查询,也可以使用oracle数据库工具查看,还可以用EM。我这有个自己写的sql脚本,
是平时自己看公司数据库表空间状态时用的。你可以参考下:.查看所有表空间的碎片程度(值在30以下表示碎片很多)
select tablespace_name, sum(bytes), sum(free), sum(free) * 100 / sum(bytes)
from (select b.file_id file_ID,
b.tablespace_name tablespace_name,
b.bytes Bytes,
(b.bytes - sum(nvl(a.bytes, 0))) used,
sum(nvl(a.bytes, 0)) free,
sum(nvl(a.bytes, 0)) / (b.bytes) * 100 Percent
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)
group by tablespace_name
order by sum(free) * 100 / sum(bytes) ;
查看表空间是否自动扩展
select file_name,autoextensible,
increment_by from dba_data_files;
表空间自动扩展
alter database datafile 'path:\datafile name'
autoextend on next 1M maxsize 100M;
表空间大小
select tablespace_name,count(*),sum(blocks),
sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
使用情况
select df.tablespace_name "表空间名",--表空间名
totalspace "总空间M",
freespace "剩余空间M",
round((1 - freespace / totalspace) * 100, 2) "使用率%"
from (select tablespace_name, round(sum(bytes) / 1024 / 1024) totalspace
from dba_data_files
group by tablespace_name) df,
(select tablespace_name, round(sum(bytes) / 1024 / 1024) freespace
from dba_free_space
group by tablespace_name) fs
where df.tablespace_name = fs.tablespace_name;
是平时自己看公司数据库表空间状态时用的。你可以参考下:.查看所有表空间的碎片程度(值在30以下表示碎片很多)
select tablespace_name, sum(bytes), sum(free), sum(free) * 100 / sum(bytes)
from (select b.file_id file_ID,
b.tablespace_name tablespace_name,
b.bytes Bytes,
(b.bytes - sum(nvl(a.bytes, 0))) used,
sum(nvl(a.bytes, 0)) free,
sum(nvl(a.bytes, 0)) / (b.bytes) * 100 Percent
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)
group by tablespace_name
order by sum(free) * 100 / sum(bytes) ;
查看表空间是否自动扩展
select file_name,autoextensible,
increment_by from dba_data_files;
表空间自动扩展
alter database datafile 'path:\datafile name'
autoextend on next 1M maxsize 100M;
表空间大小
select tablespace_name,count(*),sum(blocks),
sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
使用情况
select df.tablespace_name "表空间名",--表空间名
totalspace "总空间M",
freespace "剩余空间M",
round((1 - freespace / totalspace) * 100, 2) "使用率%"
from (select tablespace_name, round(sum(bytes) / 1024 / 1024) totalspace
from dba_data_files
group by tablespace_name) df,
(select tablespace_name, round(sum(bytes) / 1024 / 1024) freespace
from dba_free_space
group by tablespace_name) fs
where df.tablespace_name = fs.tablespace_name;