ORACLE 表空间扩展

最近公司在对即将上线的系统做数据迁移和压力测试,于是乎需要和 Oracle 经常的打交道。今天正好碰到了表空间的问题,记录下来以后备用。也是最近才学习到的,原来 Oracle 表空间也是有大小限制的,比如公司安装的 Oracle 单个 dbf 最大 31GB,所以当一个表空间文件达到最大值后就无法再增长了。需要再开辟一个表空间文件。

查看表空间的名字和物理路径

select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name

增加表空间大小

-- \chenglong\oracle\xxx.dbf 为表空间物理路径
alter database datafile '\chenglong\oracle\xxx.dbf' resize 1000M

设置表空间自动扩展

alter database datafile '\chenglong\oracle\xxx.dbf'
autoextend on next 100M [maxsize 10000M]

增加表空间数据文件

alter tablespace XXXTableSpace
add datafile '\chenglong\oracle\xxx2.dbf' size 1000m

查看表空间使用情况

select a.tablespace_name,a.bytes/1024/1024 "sum MB",
(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",
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
order by ((a.bytes-b.bytes)/a.bytes) desc;

本文由个人 hexo 博客 co2fe.com 迁移
date: 2017-09-28 22:08:03

posted @ 2018-12-28 15:38  LiuChengloong  阅读(681)  评论(0编辑  收藏  举报