檢視表空間使用情況

2021-10-11 20:24:16 字數 1301 閱讀 3711

select upper(a.tablespace_name) "表空間名",

d.tot_grootte_mb "表空間大小(m)",

d.tot_grootte_mb - a.total_bytes "已使用空間(m)",

to_char(round((d.tot_grootte_mb - a.total_bytes) / d.tot_grootte_mb * 100,

2),'990.99') || '%' "使用比",

a.total_bytes "空閒空間(m)",

a.max_bytes "最大塊(m)",

d.autoextensible "是否自增長",

d.incrementsize "自增長大小(m)",

d.create_time "建立時間"

from (select t.tablespace_name,

round(sum(t.bytes) / (1024 * 1024), 2) as total_bytes,

round(max(t.bytes) / (1024 * 1024), 2) as max_bytes

from sys.dba_free_space t

group by t.tablespace_name) a,

(select b.autoextensible,

round(sum(b.bytes) / (1024 * 1024), 2) tot_grootte_mb,

round(b.increment_by *

(select value

from v$parameter

where name = 'db_block_size') / (1024 * 1024),

2) as incrementsize,--自增長大小為資料庫中資料塊的個數,乙個資料塊一般為8k

b.tablespace_name,

min(c.creation_time) create_time--獲取建立時間,如果有多個資料檔案,獲取到最初時間

from sys.dba_data_files b, v$datafile c

where b.file_id = c.file#

group by b.tablespace_name, b.autoextensible, b.increment_by) d

where a.tablespace_name = d.tablespace_name

--and a.tablespace_name= 'users'

order by d.create_time;

檢視表的空間使用情況

在 中,可以直接在表的屬性中看到表的大小和索引檔案大小,而後 中卻不能直接看到,需要用以下 來實現,其實o.name like 是用來篩選表的名字的 if not exists select from dbo.sysobjects where id object id n dbo tablespac...

Oracle檢視表空間使用情況

關鍵字 oracle檢視表空間使用情況 說明 下面是通用的sql語句 無需任何修改 如何使用 登陸乙個資料庫例項後,直接複製下面的sql語句並執行即可。登陸特定資料庫 sqlplus sys root as sysdba vwdb dba身份登陸 sqlplus sys root vwdb 普通使用...

檢視表空間使用情況sql語句

select b.file name 物理檔名,b.tablespace name 表空間,b.bytes 1024 1024 大小m,b.bytes sum nvl a.bytes,0 1024 1024 已使用m,substr b.bytes sum nvl a.bytes,0 b.bytes ...