查询目前表空间使用情况
select a.tablespace_name,
a.bytes/1024/1024 || 'M' total,
b.bytes/1024/1024 || 'M' used,
c.bytes/1024/1024 || 'M' free,
(b.bytes * 100) / a.bytes "% USED ",
(c.bytes * 100) / a.bytes "% FREE "
from sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c
where a.tablespace_name = b.tablespace_name
and a.tablespace_name = c.tablespace_name;
查询目前表空间数据文件使用情况
select files.file_id 数据文件序号, files.file_name 数据文件路径, files.tablespace_name 表空间名称,
to_char(files.maxbytes /1024/1024/1024, '9999.00') || 'G' 数据文件最大容量,
to_char(files.bytes /1024/1024/1024, '9999.00') || 'G' 数据文件目前大小,
to_char(sum(nvl(free.bytes, 0))/1024/1024/1024, '9999.00') || 'G' 数据文件空闲大小,
to_char((sum(nvl(free.bytes, 0))/1024/1024/1024)*100 / (files.maxbytes /1024/1024/1024), '999.0') || '%'
from dba_data_files files
inner join v$datafile filesInf on files.file_id = filesInf.file#
left join dba_free_space free on files.file_id = free.file_id
group by files.file_id, files.file_name, files.tablespace_name,
files.maxbytes /1024/1024/1024,
to_char(files.maxbytes /1024/1024/1024, '9999.00') || 'G',
to_char(files.bytes /1024/1024/1024, '9999.00') || 'G'
order by files.file_id;
增加30G大小的数据文件
alter tablespace 表空间名 add datafile '/u02/app/oracle/oradata/orcl/users03.dbf' size 50M autoextend on next 50M maxsize 30720M;
创建一个新的表空间
create tablespace 表空间名 datafile '数据文件名' size 表空间大小;
create tablespace 表空间名 datafile '数据文件名' size 50M autoextend on next 50M maxsize 30720M;