转自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