查看表空间

--查看某表的大小--
select sum(bytes) / (1024 * 1024) as "size(M)"
  from user_segments
 where segment_name = upper('tbl_mo_part_00');

--查看索引个数和类别 --
select index_name, index_type, table_name, t.sample_size
  from user_indexes t
 order by table_name;
 
--查看索引的大小 --
select sum(bytes) / (1024 * 1024) as "size(M)"
  from user_segments
 where segment_name = upper('TBL_MO_PART_01');

    
--查看表空间的使用情况 和 物理空间大小--  
select t.tablespace_name,d.file_name,sum(t.bytes)/(1024*1024) as "free_space(M)",round(d.bytes/(1024*1024),0) "total_space(M)"
    from dba_free_space t, dba_data_files d
    where t.tablespace_name = d.tablespace_name 
    group by t.tablespace_name,d.file_name,d.bytes; 
    







--下面的语句用来查询哪些对象被锁--
select object_name,machine,s.SID,s.SERIAL# from v$locked_object l,dba_objects o, v$session s
where l.OBJECT_ID = o.object_id and l.SESSION_ID = s.SID;

--杀死一个被锁的进程,要用到上面的结果
alter system kill session 'SID';

--查看锁表进程
select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID; 
 
 

你可能感兴趣的:(表空间)