记录下相关命令:需要注意的是,一般创建表空间对应的数据文件时,会指定数据文件默认大小,但是这个地方是很容易理解错误的,因为查询表空间使用情况的sql查询出来的是当前的占用大小,比如数据文件初始大小1G,当900M时占比很高,但是
此文件可能是可扩展的,所以及时900M了,仍然是没有问题的。
select * from dba_data_files where tablespace_name='TS_INDEX';
ALTER TABLESPACE TS_INDEX add DATAFILE '+ORADATA/PRO_BUSINESS/DATAFILE/invoice_saft6_tbs.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M ;
ALTER TABLESPACE XXX add DATAFILE '+ORADATA/PRO_BUSINESS/DATAFILE/invoice_saft7_tbs.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M ;
ALTER TABLESPACE XXX add DATAFILE '+ORADATA/PRO_BUSINESS/DATAFILE/invoice_saft8_tbs.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M ;
select total.tablespace_name,
Total.AUTOEXTENSIBLE,
round(total.MB,2) as total_MB,
round(total.MB-free.MB,2) as USED_MB,
round((1-free.MB/total.MB)*100,2) as "USED_PCT(%)",
round(free.MB,2) as free_MB
from
(
select a.tablespace_name,
sum(a.bytes)/1024/1024 as MB,
AUTOEXTENSIBLE
from sys.dba_data_files a
group by a.tablespace_name,AUTOEXTENSIBLE
) total,
(
select
b.tablespace_name,
count(1) as extends,
sum(b.bytes)/1024/1024 as MB,
sum(b.blocks) as blocks
from sys.dba_free_space b
group by b.tablespace_name
) free
where total.tablespace_name=free.tablespace_name and free.tablespace_name=''
order by total.tablespace_name;
需要注意的是,表空间和临时表空间不是一个概念:
select * from dba_temp_files where tablespace_name = 'TEMP' ;
注意temp这个词,上面的是data,这个地方跟报错的信息是紧密联系的,一定要看清楚是什么表空间不足,从而查询对应的剩余空间是多少。
select * from dba_temp_files where tablespace_name = 'TEMP' ;也可以看出使用情况