*需定期查看表空间,如没有足够的空间,数据无法存储,业务系统会报错*
1、查询表空间大小:
select tpsname "TBS_NAME",status "STATUS",mgr "SEGMENT", maxsize "MAX_SIZE(M)",c_userd "USED%",max_used "MAX_USED%" from (
SELECT d.tablespace_name tpsname,d.status status,
d.segment_space_management mgr, d.contents type,
TO_CHAR(NVL(trunc(A.maxbytes / 1024 / 1024), 0),'99G999G990') maxsize,
TO_CHAR(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0),'990D00') c_userd,
TO_CHAR(NVL((a.bytes - NVL(f.bytes, 0)) / a.maxbytes * 100, 0),'990D00') max_used
FROM sys.dba_tablespaces d,
(SELECT tablespace_name,sum(bytes) bytes,SUM(case autoextensible when 'NO' then BYTES when 'YES' then MAXBYTES else null end ) maxbytes FROM dba_data_files GROUP BY tablespace_name) a,
(SELECT tablespace_name,SUM(bytes) bytes, MAX(bytes) largest_free FROM dba_free_space GROUP BY tablespace_name) f
WHERE d.tablespace_name = a.tablespace_name AND d.tablespace_name = f.tablespace_name(+)
)
order by max_used desc;
查询结果:
2、查询表空间路径:
select file_name,tablespace_name,AUTOEXTENSIBLE,bytes/1024/1024/1024||'G',MAXBYTES/1024/1024/1024||'G'
from dba_data_files where tablespace_name='表空间名称'; --表空间名称更换你自己的表空间
查询结果:
3、新增表空间:
alter tablespace 表空间 add datafile '+路径 /表空间名称.dbf' size 100M autoextend on;
--表空间名称更换你自己的表空间
--路径 /表空间名称.dbf更换为序号2中“File_name”,如新增data25,最后一个是24.