查询表空间剩余内存
SELECT TABLESPACE_NAME "表空间",
To_char(Round(BYTES / 1024, 2), '99990.00')
|| '' "实有",
To_char(Round(FREE / 1024, 2), '99990.00')
|| 'G' "现有",
To_char(Round(( BYTES - FREE ) / 1024, 2), '99990.00')
|| 'G' "使用",
To_char(Round(10000 * USED / BYTES) / 100, '99990.00')
|| '%' "比例"
FROM (SELECT A.TABLESPACE_NAME TABLESPACE_NAME,
Floor(A.BYTES / ( 1024 * 1024 )) BYTES,
Floor(B.FREE / ( 1024 * 1024 )) FREE,
Floor(( A.BYTES - B.FREE ) / ( 1024 * 1024 )) USED
FROM (SELECT TABLESPACE_NAME TABLESPACE_NAME,
Sum(BYTES) BYTES
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) A,
(SELECT TABLESPACE_NAME TABLESPACE_NAME,
Sum(BYTES) FREE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) B
WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME)
--WHERE TABLESPACE_NAME LIKE 'CDR%' --这一句用于指定表空间名称
ORDER BY Floor(10000 * USED / BYTES) DESC;
查询文件路径
select b.file_id 文件ID,
b.tablespace_name 表空间,
b.file_name 物理文件名,
b.bytes 总字节数,
(b.bytes-sum(nvl(a.bytes,0))) 已使用,
sum(nvl(a.bytes,0)) 剩余
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_name,b.file_id,b.bytes
order by b.tablespace_name
表空间添加新数据文件扩容
一个表文件最大只能32G
给MY_01表空间扩容(直接将数据文件设置成最大)
ALTER TABLESPACE MY_01 ADD DATAFILE '/ibmp_data/oracle/oradata/hdyy_sjpt_ts/my_13.dbf’ size 30768M ;
手工改变已存在数据文件的大小
ALTER TABLESPACE MY_01 ADD DATAFILE '/ibmp_data/oracle/oradata/hdyy_sjpt_ts/my_13.dbf’ size 30768M ;
允许已存在的数据文件自动增长(每次100M)
ALTER DATABASE DATAFILE '/ibmp_data/oracle/oradata/hdyy_sjpt_ts/my_13.dbf’ AUTOEXTEND ON NEXT 100M MAXSIZE 20480M;