查看表空间使用情况

来源:互联网 发布:淘宝移动端店铺装修 编辑:程序博客网 时间:2024/05/17 21:42

转自http://suan2046.iteye.com/blog/379544

查找表空间对应数据文件的路径:
select file_name from dba_data_files where tablespace_name = 'TESTSPACE';

所有表空间大小
select tablespace_name,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name; 

未使用的表空间大小 
select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by tablespace_name; 

所有使用空间可以这样计算:
select a.tablespace_name,total,free,total-free used from 
( select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files 
group by tablespace_name) a, 
( select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space 
group by tablespace_name) b 
where a.tablespace_name=b.tablespace_name; 

表空间各用户使用情况
select SEGMENT_TYPE,owner,sum(bytes)/1024/1024 from 
       dba_segments
       where tablespace_name='TESTSPACE'
      group by segment_type,owner

增加表空间大小:
可以为表空间增加数据文件:
alter tablespace users add datafile 'c:\oracle\ora81\oradata\sid\user002.dbf' size 100M;
也可以增加表空间原有数据文件尺寸:
alter database datafile 'c:\oracle\ora81\oradata\sid\users.dbf' resize 1000M

在命令行情况下如何将结果放到一个文件里
SQL> spool out.txt 
SQL> select * from v$database; 
SQL> spool off

0 0
原创粉丝点击