原因:
Oracle的表空间不足了,导致数据无法插入。
处理方法:
第一步、查看表空间使用情况
select upper(f.tablespace_name) as "表空间名称",
round(d.availb_bytes, 4) as "表空间分配大小(G)",
round((d.availb_bytes - f.free_bytes), 4) as "分配空间已使用大小(G)",
round(f.free_bytes, 4) as "分配空间剩余大小(G)",
to_char(round((d.availb_bytes - f.free_bytes) / d.availb_bytes * 100,
2),
'999.99') || '%' as "分配空间使用率",
round((d.max_bytes - d.availb_bytes + f.free_bytes), 4) as "可用空间大小(G)",
round(d.max_bytes, 4) as "表空间最大大小(G)",
to_char(round((d.max_bytes - d.availb_bytes + f.free_bytes) /
d.max_bytes * 100,
4),
'999.9999') || '%' as "表空间空闲率"
from (select tablespace_name,
round(sum(bytes) / (1024 * 1024 * 1024), 6) free_bytes,
round(max(bytes) / (1024 * 1024 * 1024), 6) max_bytes
from sys.dba_free_space
group by tablespace_name) f,
(select dd.tablespace_name,
round(sum(dd.bytes) / (1024 * 1024 * 1024), 6) availb_bytes,
round(sum(decode(dd.maxbytes, 0, dd.bytes, dd.maxbytes)) /
(1024 * 1024 * 1024),
6) max_bytes
from sys.dba_data_files dd
group by dd.tablespace_name) d
where d.tablespace_name = f.tablespace_name
order by 3 desc;
可以看到我们的表空间确实已经不足了。
第二步、查看表空间的位置,以及各个数据文件信息
SELECT a.tablespace_name,
a.file_name,
a.file_id,
ROUND(a.bytes / 1024 / 1024, 2) AS "分配大小_M",
ROUND(c.bytes / 1024 / 1024, 2) AS "剩余大小_M",
ROUND(a.maxbytes / 1024 / 1024, 2) AS "最大大小_M",
a.autoextensible
FROM dba_data_files a
JOIN (select file_id, sum(bytes) as bytes
from dba_free_space
where tablespace_name = '这里输入表空间的名字'
group by file_id) c
ON a.file_id = c.file_id;
可以看到我们几个数据文件剩余的大小都不足了,这时我们就要增加新的数据文件了。
第三步、新增数据文件
alter tablespace 表空间名字 add datafile '这里数据你的数据文件地址' size 1024m autoextend on next 100m;
例如
alter tablespace TBS_XXX add datafile '/oradata/datafile/powersmart/TBS_XXX004.dbf' size 1024m autoextend on next 100m;
TBS_XXX004.dbf 这个文件名自己命名,建议表空间名字+排序号