目录
- 1、表空间容量指标查询
- 2、表空间扩容
- 方式1:手工改变已存在数据文件的大小
- 方式2:允许已存在的数据文件自动增长
- 方式3:增加数据文件
1、表空间容量指标查询
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)) 剩余, 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
2、表空间扩容
一个数据文件最大只能32g;
方式1:手工改变已存在数据文件的大小
alter tablespace app_data add datafile 'd:\oracle\product.2.0\oradata\edwtest\app03.dbf' size 20480m;
方式2:允许已存在的数据文件自动增长
alter database datafile 'd:\oracle\product.2.0\oradata\edwtest\app03.dbf' autoextend on next 100m maxsize 20480m;
方式3:增加数据文件
其中设置的每个文件初始分配空间为7g, autoextend on为自动增长大小,oracle单个文件大小最大不超过32g.
sql脚本如下:(我这里增加两个数据文件,需要扩容的表空间是system)
alter tablespace system add datafile 'c:\app\oracle\oradata\dfyycdb\datafile\o2_mf_system_cwmnz9xv_.dbf' size 7167m autoextend on ; alter tablespace system add datafile 'c:\app\oracle\oradata\dfyycdb\datafile\o3_mf_system_cwmnz9xv_.dbf' size 7167m autoextend on ;
到此这篇关于oracle表空间扩容详情的文章就介绍到这了,更多相关oracle表空间扩容内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!