ora-20999,表空间满了处理办法:

前几天遇到一家客户报错ora-20999的错误,现将处理方式分享一下:

1.表空间使用率查询,其中,最大使用使用率来判断是否增加数据文件:

select a.tablespace_name As 表空间,f.文件数,round(f.最大值 / 1024,2) || 'GB' as max,

round(to_number(total - free) / to_number(最大值) * 100, 2) as 最大使用率,

total || 'M' As 空间大小,free || 'M' As 剩余空间,total - free || 'M' 已使用,

round(to_number(total - free) / to_number(total) * 100, 2) As 实际使用率

from (select tablespace_name, round(sum(bytes) /(1024*1024),2) total

from dba_data_files

group by tablespace_name) a,

(select tablespace_name, round(sum(bytes) /(1024*1024),2) free

from dba_free_space

group by tablespace_name) b,

(select d.name, count(*) as 文件数, sum(decode(c.autoextensible,'YES',c.maxbytes,c.bytes))/1024/1024 as 最大值

from dba_data_files c, v$tablespace d

where c.tablespace_name = d.name

group by d.name) f

where a.tablespace_name = b.tablespace_name

and a.tablespace_name = f.name

order by 最大使用率 desc

-----可根据以上语句判断哪个表空间满了,需要扩展

2.查询表空间数据文件位置:(方法有二)

(1)select * from dba_data_files

(2)select tablespace_name, file_id, file_name, round(bytes / (1024 * 1024), 0) total_space from sys.dba_data_files order by tablespace_name

-----file_name就是表空间数据文件的路径及名称

3.扩展表空间数据文件:(方法有三)

(1)新增一个数据文件:

Alter tablespace 表空间名 add datafile ‘数据文件路径.dbf’ size 500M autoextend on next 100M maxsize unlimited;

举例:alter tablespace test add datafile 'E:\oradata\orcl\test01.dbf' size 3200m

           test01.dbf为新增的数据文件的名称, test为扩展的表空间

(2)手动增加表空间数据文件的大小:

      alter database datafile 'E:\oradata\orcl\test01.dbf' resize 4096m

       -----test01.dbf为需要修改大小的数据文件

(3)将表空间的数据文件设置成自动扩展:

     alter database datafile 'E:\oradata\orcl\test01.dbf' autoextend on next 5M maxsize unlimited;

     -----test01.dbf为设置自动扩展的数据文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

&小汤

大家共同学习

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值