Oracle 在原有的表空间(Tablespace)上增加新的数据文件
一、查询原数据文件所在的位置(以及数据文件大小),以便新数据文件创建到该位置 selecttablespace_name,
file_id,
file_name,round(bytes/(1024*1024*1024),0)
total_space_size_GB from dba_data_files where tablespace_name=表空间名称 order by tablespace_name
二:增加数据文件
alter tablespace表空间名称
add datafile '新的数据文件地址' size 初始数据文件大小
altertablespace BI
adddatafile 'D:\\DATA\\BI02.DBF' size 1024m
三:设置表空间自动扩展。
注意:Oracle 的最大数据文件大小为32G,因此,建议设置最大大小为30G alter database datafile '数据文件位置'
autoextend on next 自动扩展大小 maxsize 最大扩展大小
alter database datafile 'D:\\DATA\\BI02.DBF' autoextend on next 1024m maxsize 30720m
四:查询表空间使用情况: select
a.tablespace_name,
a.bytes/1024/1024/1024 \
(a.bytes-b.bytes)/1024/1024/1024 \b.bytes/1024/1024/1024 \
round (((a.bytes-b.bytes)/a.bytes)*100,2) \ from
(selecttablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
(selecttablespace_name,sum(bytes)
bytes,max
(bytes)
largest
from
dba_free_space group by tablespace_name) b wherea.tablespace_name=b.tablespace_name order by ((a.bytes-b.bytes)/a.bytes) desc;
--附:查看当前用户每个表的大小,可能会花较长时间
Select Segment_Name,Sum(bytes)/1024/1024 as table_size_MB From User_Extents Group By Segment_Name
相关推荐: