1.查詢使用者(資料)表空間
select upper(f.tablespace_name) "表空間名",
d.tot_grootte_mb "表空間大小(m)",
d.tot_grootte_mb - f.total_bytes "已使用空間(m)",
to_char(round((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100,
2),
'990.99') "使用比",
f.total_bytes "空閒空間(m)",
f.max_bytes "最大塊(m)"
from (select tablespace_name,
round(sum(bytes) / (1024 * 1024), 2) total_bytes,
round(max(bytes) / (1024 * 1024), 2) max_bytes
from sys.dba_free_space
group by tablespace_name) f,
(select dd.tablespace_name,
round(sum(dd.bytes) / (1024 * 1024), 2) tot_grootte_mb
from sys.dba_data_files dd
group by dd.tablespace_name) d
where d.tablespace_name = f.tablespace_name
order by 4 desc
2.查詢臨時表空間
select d.status "status", d.tablespace_name "name", d.contents "type",
d.extent_management "extent management",
to_char (nvl (a.bytes / 1024 / 1024, 0), '99,999,990.900') "size (m)",
to_char (nvl (t.bytes, 0) / 1024 / 1024, '99999999.999')
|| '/'
|| to_char (nvl (a.bytes / 1024 / 1024, 0), '99999999.999') "used (m)",
to_char (nvl (t.bytes / a.bytes * 100, 0), '990.00') "used %"
from sys.dba_tablespaces d,
(select tablespace_name, sum (bytes) bytes
from dba_temp_files
group by tablespace_name) a,
(select tablespace_name, sum (bytes_cached) bytes
from v$temp_extent_pool
group by tablespace_name) t
where d.tablespace_name = a.tablespace_name(+)
and d.tablespace_name = t.tablespace_name(+)
and d.extent_management like 'local'
and d.contents like 'temporary'
-- 收縮臨時表空間
alter tablespace tbs_mk_temp coalse;
3.查詢某個使用者下表 占用的空間
select t.segment_name,sum(t.bytes)/1024/1024
from user_segments t
where segment_name like 'tb%'
group by t.segment_name
order by sum(t.bytes)/1024/1024 desc
4.查詢表是否是分割槽表 ,占用的大小
select *
from user_segments t
where segment_name like 'tb%'
and t.segment_name='tb_fi_fig_winner_cust_mon'
5.查詢 被鎖的程序(dba登入)
select sess.sid,sess.serial#, lo.oracle_username,lo.os_user_name,ao.object_name, sess.logon_time,lo.locked_mode
from v$locked_object lo,dba_objects ao,v$session sess
where ao.object_id = lo.object_id
and lo.session_id = sess.sid
order by sess.logon_time;
6. 殺掉被鎖的程序
alter system kill session '1997,33097';
oracle 表空間 查詢
知道表空間名,顯示該錶空間包括的所有表。select from all tables where tablespace name 表空間名 知道表名,檢視該錶屬於那個表空間 select tablespace name,table name from user tables where table ...
Oracle表空間查詢
查詢表空間使用情況 select upper f.tablespace name 表空間名 d.tot grootte mb 表空間大小 m d.tot grootte mb f.total bytes 已使用空間 m to char round d.tot grootte mb f.total b...
oracle 查詢表空間
測試使用者連線 c users zp sqlplus nolog conn hbcxuser hbcxpass 檢視所有表空間 select from user tablespaces 檢視資料庫裡面所有使用者,前提是你是有dba許可權的帳號,如sys,system select username ...