1、檢視表空間的名稱及大小
select t.tablespace_name as"表空間名",
round(sum(bytes / (1024
*1024)), 0) as
"所佔物理空間m"
from
dba_tablespaces t, dba_data_files d
where t.tablespace_name =
d.tablespace_name
group
by t.tablespace_name;
2.檢視表空間物理檔案的名稱及大小
select tablespace_name as"表空間名",
file_id
as"資料檔案序號",
file_name
as"資料檔案所在位置",
round(bytes / (1024
*1024), 0) as
"所佔物理空間(m)"
from
dba_data_files
order
by tablespace_name;
3.查詢表空間的使用情況
1)以m為單位
selectupper
(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
bytablespace_name) f,
(select
dd.tablespace_name,
round(sum(dd.bytes) / (1024
*1024), 2
) tot_grootte_mb
from
sys.dba_data_files dd
group
bydd.tablespace_name) d
where d.tablespace_name =
f.tablespace_name
order
by1;
2)以g為單位
selecta.tablespace_name "表空間名",
total "表空間大小",
free "表空間剩餘大小",
(total
-free) "表空間使用大小",
total
/ (1024
*1024
*1024
) "表空間大小(g)",
free
/ (1024
*1024
*1024
) "表空間剩餘大小(g)",
(total
- free) / (1024
*1024
*1024
) "表空間使用大小(g)",
round((total - free) / total, 4) *
100 "使用率 %
" from (select tablespace_name, sum
(bytes) free
from
dba_free_space
group
bytablespace_name) a,
(select tablespace_name, sum
(bytes) total
from
dba_data_files
group
bytablespace_name) b
where a.tablespace_name = b.tablespace_name
檢視表占用空間資訊
if not exists select from dbo.sysobjects where id object id n dbo tablespaceinfo and objectproperty id,n isusertable 1 create table tablespaceinfo 建立臨...
檢視表空間
檢視某錶的大小 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 n...
利用 Sql 中檢視表結構資訊
1 select 表名 case when a.colorder 1 then d.name else end,表說明 case when a.colorder 1 then isnull f.value,else end,字段序號 a.colorder,欄位名 a.name,標識 case whe...