Oracle查询表空间及表大小
一、Oracle物理表空间查询
select b.file_name phy_file_name, 
       b.tablespace_name tablespace_name, 
       b.bytes / 1024 / 1024 || ' MB' tabspace_bytes, 
       (b.bytes - sum(nvl(a.bytes, 0))) / 1024 / 1024 || ' MB' USEED_SPACE, 
       b.bytes / 1024 / 1024 -(b.bytes - sum(nvl(a.bytes, 0))) / 1024 / 1024 || ' MB'  Free_Space, 
       substr((b.bytes - sum(nvl(a.bytes, 0))) / (b.bytes) * 100, 1, 5) || '%' use_ratio 
  from dba_free_space a, dba_data_files b
 where a.file_id = b.file_id
 group by b.tablespace_name, b.file_name, b.bytes
 order by b.tablespace_name;
二、查询特定的表所在的表空间以及所在的物理文件上
select a.table_name, a.tablespace_name, b.file_name
  from user_tables a, dba_data_files b
 where a.tablespace_name = b.tablespace_name
   and a.table_name = 'CORP_RICH_ORDERTRADENIGHT';
三、更改数据库的默认表空间
Alter database  default  tablespace tablespace_name;(数据表空间)
Alter database  temporary tablespace tablespace_name;(临时数据表空间)
四、查询表大小
Select Segment_Name, Sum(bytes) / 1024 / 1024 || 'MB'
From User_Extents u where u.segment_type='TABLE'
Group By Segment_Name;