日期:2014-05-16 浏览次数:20449 次
oracle表空间的事儿情况要常常查看,正常闲空比率过低的时分就应该思考增大表看空间了。查看步骤如次SQL:
步骤1:
select dbf.tablespace_name,
dbf.totalspace "总量(M)",
dbf.totalblocks as 总块数,
dfs.freespace "余下总量(M)",
dfs.freeblocks "余下块数",
(dfs.freespace / dbf.totalspace) * 100 "闲空比率"
from (select t.tablespace_name,
sum(t.bytes) / 1024 / 1024 totalspace,
sum(t.blocks) totalblocks
from dba_data_files t
group by t.tablespace_name) dbf,
(select tt.tablespace_name,
sum(tt.bytes) / 1024 / 1024 freespace,
sum(tt.blocks) freeblocks
from dba_free_space tt
group by tt.tablespace_name) dfs
where trim(dbf.tablespace_name) = trim(dfs.tablespace_name)
步骤2:
SELECT Total.name "Tablespace Name",
Free_space, (total_space-Free_space) Used_space, total_space
FROM
(select tablespace_name, sum(bytes/1024/1024) Free_Space
from sys.dba_free_space
group by tablespace_name
) Free,
(select b.name, sum(bytes/1024/1024) TOTAL_SPACE
from sys.v_$datafile a, sys.v_$tablespace B
where a.ts# = b.ts#
group by b.name
) Total
WHERE Free.Tablespace_name = Total.name
应发幸存的表空间不够的差错时,处置如次:
一:找到该表空间对应的数据文件及途径
select * from dba_data_files t
where t.tablespace_name = 'ARD'
二:增大数据文件
alter database datafile '全途径的数据文件姓名' resize ***M
三:增加数据文件
alter tablespace 表空间姓名
add datafile '全途径的数据文件姓名' ***M
诠注:表空间尽可能让free百分比保持在十%之上,如若仅次于十%便增多datafile也许resizedatafile,通常数据文件不用超过二G