ORACLE資料庫表空間查詢

2022-08-29 05:36:10 字數 1052 閱讀 4989

前提:必須有dba許可權,有許可權查詢表空間使用情況

--檢視表空間使用情況

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 1;

--檢視某個表的表空間使用情況

select a.owner,a.segment_name,a.bytes,a.bytes/ 1024 / 1024 as mb from dba_segments a where a.segment_name like 'tablename%';

select * from dba_segments a where a.segment_name like 'tablename%';

Oracle資料庫查詢使用者表空間查詢 建立

檢視資料庫裡面所有使用者,前提是你是有dba許可權的帳號,如sys,system select from dba users 檢視你能管理的所有使用者 select from all users 檢視當前使用者資訊 select from user users 查詢使用者所對應的表空間 select...

oracle 資料庫表空間

1 建立表空間 格式 建立表空間 create tablespace 表空間名 datafile 表空間檔案儲存物理路徑.ora size 500m defaultstorage autoextend on initial 100m next 100m minextents 20 maxextent...

Oracle資料庫表空間

永久表空間 表空間是資料庫的邏輯劃分,乙個表空間只屬於乙個資料庫。所有的資料庫物件都存放在指定的表空間中。但主要存放的是表,所以稱作表空間 臨時表空間 oracle臨時表空間主要用來做查詢和存放一些緩衝區的資料。臨時表空間消耗的主要原因是需要讀查詢的中間結果進行排序。重啟資料庫可以釋放臨時表空間 建...