1、查询各个表空间使用的大小
SELECT
tbs USERS,
SUM (totalM) 总共大小M,
SUM (usedM) 已使用空间M,
SUM (remainedM) 剩余空间M,
SUM (usedM) / SUM (totalM) * 100 已使用百分比,
SUM (remainedM) / SUM (totalM) * 100 剩余百分比
FROM
(
SELECT
b.file_id ID,
b.tablespace_name tbs,
b.file_name NAME,
b.bytes / 1024 / 1024 totalM,
(
b.bytes - SUM (NVL(A .bytes, 0))
) / 1024 / 1024 usedM,
SUM (NVL(A .bytes, 0) / 1024 / 1024) remainedM,
SUM (
NVL (A .bytes, 0) / (b.bytes) * 100
),
(
100 - (
SUM (NVL(A .bytes, 0)) / (b.bytes) * 100
)
)
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
)
GROUP BY
tbs
2、查询需要扩容表空间的的数据文件路径
select * from dba_data_files where tablespace_name='USERS';
3、对需要扩容的表空间增加数据文件
ALTER TABLESPACE USERS ADD DATAFILE 'D:\APP\11.2.0\GRID\ORADATA\DATA\USEREx.DBF' SIZE 32767M;