oracle 数据库怎么查看temp表空间使用情况

2024-11-26 14:49:03
推荐回答(1个)
回答1:

oracle
数据库里查看表空间使用状况;
oracle表空间的事情状况要经常查看,一般空闲比例过低的时候就应该考虑增大表看空间了。查看方法如下sql:
方法一:
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)
方法二:
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
当发现有的表空间不够的错误时,处理如下:
1:找出该表空间对应的数据文件及路径
select
*
from
dba_data_files
t
where
t.tablespace_name
=
'ard'
2:增大数据文件
alter
database
datafile
'全路径的数据文件名称'
resize
***m
3:增加数据文件
alter
tablespace
表空间名称
add
datafile
'全路径的数据文件名称'
***m
注解:表空间尽量让free百分比保持在10%以上,如果低于10%就增加datafile或者resizedatafile,一般数据文件不要超过2g