oralce表空间不足需要扩展表空间来存储数据,本质上是扩大数据文件的大小,或者增加数据文件的数量。
查询表空间大小:
select
t.tablespace_name,
sum(t.bytes/1024/1024/1024) GB
from
dba_data_files t
group by t.tablespace_name;
查询剩余表空间大小:
select
t.tablespace_name,
sum(t.bytes/1024/1024/1024) GB
from
dba_free_space t
group by t.tablespace_name;
查询表空间使用率:
select a.tablespace_name,
a.bytes / 1024 / 1024 /1024 "sum GB",
(a.bytes - b.bytes) / 1024 / 1024 /2014 "used GB",
b.bytes / 1024 / 1024 / 1024 "free GB",
round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "used%"
from (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes, max(bytes) largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name;
一、通过查询对应表空间的数据文件,改变该数据文件的大小
--alter database datafile '数据文件' resize '新的大小';
--举例如下:
alter database datafile '/data/oradata/test01.dbf' resize 1000m;
二、通过增加数据文件个数来达到扩展表空间的目的
--alter tablespace '表空间名称' add datafile '新的数据文件' size '数据文件大小';
--举例如下:
alter tablespace testspace01 add datafile '/data/oradata/test09.dbf' size 1000m;
也可以设置数据文件自增来达到表空间自动增长的目的(maxsize可写可不写):
--alter database datafile '数据文件' autoextend on next '自增大小' maxsize '数据文件最大值';
alter database datafile '/data/oradata/test01.dbf' autoextend on next 100m maxsize 1000m;
--alter tablespace '表空间名称' add datafile '新的数据文件' size '数据文件初始大小' autoextend on next '自增大小' maxsize '数据文件最大值';
alter tablespace testspace01 add datafile '/data/oradata/test10.dbf' size 1000m autoextend on next 100m maxsize 10000m;
当Oracle表空间不足时,可通过扩大数据文件大小或增加数据文件数量来扩展。查询表空间大小、剩余空间及使用率是管理关键。调整数据文件大小或增加文件,甚至设置自增选项以实现自动增长,都是常见策略。
1917

被折叠的 条评论
为什么被折叠?



