修改oracle表空间

                      修改oracle表空间

 查看表空间的位置

select a.tablespace_name,b.file_name,a.block_size,a.block_size,b.bytes/1024
/1024 "Sum MB" from dba_tablespaces a,dba_data_files b where a.tablespace_name=b.tablespace_name;

 

查看表空间是否自动增长:
select file_name,autoextensible,increment_by from dba_data_files;

 

查看所有表空间大小情况:

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) "percent_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


查看DATATBS01'的大小情况,以及空间文件

select file_name,tablespace_name,bytes/1024/1024 "bytes MB",maxbytes/1024/1024 "maxbytes MB" from dba_data_files
where tablespace_name='DATATBS01';

 

 

为DATATBS01表空间增加,空间文件 datatbs03.dbf   大小 20G
alter tablespace DATATBS01
add datafile '/data/oracle/datatbs03.dbf'
size 10M autoextend on maxsize 20G

 

 

参考---------------------http://blog.chinaunix.net/uid-20541719-id-3014408.html

查看Oracle表空间大小的方法2011-11-09 13:23:47

分类: Oracle

磁盘空间不足问题 们经常会遇到,查看Oracle表空间大小就成了 们必须要掌握的知识,让 们了解什么时候需要增加表空间。
Oracle表空间大小的查看方法应该是 们都需要掌握的知识,下面就为您详细介绍查看 Oracle表空间大小的方法,供您参考学习。

在数据库管理中,磁盘空间不足是DBA都会遇到的问题,问题比较常见。

--1查看Oracle表空间大小--已经使用的百分比。

  1. 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) "percent_used"
  2. from
  3. (select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
  4. (select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
  5. where a.tablespace_name=b.tablespace_name
  6. order by ((a.bytes-b.bytes)/a.bytes) desc

“Sum MB”表示表空间所有的数据文件总共在操作系统占用磁盘空间的大小
比如:test表空间有2个数据文件,datafile1为300MB,datafile2为400MB,那么test表空间的“Sum MB”就是700MB
“userd MB”表示表空间已经使用了多少
“free MB”表示表空间剩余多少
“percent_user”表示已经使用的百分比

--2比如从1中查看到MLOG_NORM_SPACE表空间已使用百分比达到90%以上,可以查看该表空间总共有几个数据文件,每个数据文件是否自动扩展,可以自动扩展的最大值。

  1. select file_name,tablespace_name,bytes/1024/1024 "bytes MB",maxbytes/1024/1024 "maxbytes MB" from dba_data_files
  2. where tablespace_name='MLOG_NORM_SPACE';

--3比如MLOG_NORM_SPACE表空间目前的大小为19GB,但最大每个数据文件只能为20GB,数据文件快要写满,可以增加表空间的数据文件
用操作系统UNIX、Linux中的df -g命令(查看下可以使用的磁盘空间大小)
获取创建表空间的语句:

  1. select dbms_metadata.get_ddl('TABLESPACE','MLOG_NORM_SPACE') from dual;

--4确认磁盘空间足够,增加一个数据文件

  1. alter tablespace MLOG_NORM_SPACE
  2. add datafile '/oracle/oms/oradata/mlog/Mlog_Norm_data001.dbf'
  3. size 10M autoextend on maxsize 20G

--5验证已经增加的数据文件

  1. select file_name,file_id,tablespace_name from dba_data_files
  2. where tablespace_name='MLOG_NORM_SPACE'    --注意表空间要大写

--6如果删除表空间数据文件,如下:

  1. alter tablespace MLOG_NORM_SPACE
  2. drop datafile '/oracle/oms/oradata/mlog/Mlog_Norm_data001.dbf'


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值