1.方式一:表空間名和大小;
select t.tablespace_name, round(sum(bytes / (1024 * 1024)), 0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
顯示結果:
1 datatb 50480
2 undotbs1 5436
3 sysaux 5199
4 tbs_mediation_d01 5120
5 users 2053
6 tbs_mediation_def 5120
7 parametertb 5120
8 system 4796
9 tbs_mediation_i01 5120
10 indxtb 20480
2.方式二:表空間名和剩餘大小,使用大小,總大小;
select total.name "tablespace name",
free_space, (total_space-free_space) used_space, total_space
from
(select tablespace_name, sum(bytes/1024/1024) free_space
from sys.dba_free_space
group by tablespace_name
) free,
(select b.name, sum(bytes/1024/1024) total_space
from sys.v_$datafile a, sys.v_$tablespace b
where a.ts# = b.ts#
group by b.name
) total
where free.tablespace_name = total.name;
顯示結果:
1 datatb 9025.125 41454.875 50480
2 sysaux 3279.8125 1919.1875 5199
3 undotbs1 5410.5625 25.4375 5436
4 tbs_mediation_d01 5119.9375 0.0625 5120
5 users 2052.5 0.5 2053
6 tbs_mediation_def 4926.75 193.25 5120
7 parametertb 5118.375 1.625 5120
8 system 1981 2815 4796
9 tbs_mediation_i01 5119.9375 0.0625 5120
10 indxtb 9714.25 10765.75 20480
select a.tablespace_name "表空間名",
total 表空間大小,
free 表空間剩餘大小,
(total - free) 表空間使用大小,
round((total - free) / total, 4) * 100 "使用率 %"
from (select tablespace_name, sum(bytes) free
from dba_free_space
group by tablespace_name) a,
(select tablespace_name, sum(bytes) total
from dba_data_files
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name;
顯示結果:
1 datatb 52932116480 6322520064 46609596416 88.06
2 sysaux 5451546624 3439132672 2012413952 36.91
3 undotbs1 5700059136 5669126144 30932992 0.54
4 tbs_mediation_d01 5368709120 5368643584 65536 0
5 users 2152726528 2152202240 524288 0.02
6 tbs_mediation_def 5368709120 5166071808 202637312 3.77
7 parametertb 5368709120 5367005184 1703936 0.03
8 system 5028970496 2077229056 2951741440 58.69
9 tbs_mediation_i01 5368709120 5368643584 65536 0
10 indxtb 21474836480 10160963584 11313872896 52.68
3.方式二:最優方式;
select dbf.tablespace_name,
dbf.totalspace "總量(m)",
dbf.totalblocks as 總塊數,
dfs.freespace "剩餘總量(m)",
dfs.freeblocks "剩餘塊數",
(dfs.freespace / dbf.totalspace) * 100 "空閒比例"
from (select t.tablespace_name,
sum(t.bytes) / 1024 / 1024 totalspace,
sum(t.blocks) totalblocks
from dba_data_files t
group by t.tablespace_name) dbf,
(select tt.tablespace_name,
sum(tt.bytes) / 1024 / 1024 freespace,
sum(tt.blocks) freeblocks
from dba_free_space tt
group by tt.tablespace_name) dfs
where trim(dbf.tablespace_name) = trim(dfs.tablespace_name);
顯示結果:
1 datatb 20480 2621440 20479.4375 2621368 99.9972534179688
2 sysaux 1159.1875 148376 60.0625 7688 5.18143095918477
3 undotbs1 1555 199040 1525.5625 195272 98.1069131832797
4 tbs_mediation_d01 5120 655360 5119.9375 655352 99.998779296875
4.檢視當前使用者各表所佔表空間;
select segment_name,sum(bytes)/1024/1024 from user_extents group by segment_name;
oracle 檢視表空間大小
1.檢視所有表空間大小 sql select tablespace name,sum bytes 1024 1024 from dba data files 2 group by tablespace name 2.已經使用的表空間大小 sql select tablespace name,sum ...
oracle檢視表空間占用的大小情況
1.檢視乙個使用者所佔的空間大小 用該使用者登入 select sum bytes 1024 1024 mb from user extents u 2.檢視表空間還剩多少用 還能看每檔案情況 select b.file id 檔案id,b.tablespace name 表空間,b.file na...
oracle檢視表空間情況
查詢表空間的總容量 select tablespace name 表空間名稱,sum bytes 1024 1024 表空間總容量mb 查詢表空間使用率 select total.tablespace name 表空間名稱,round total.mb,2 總容量mb,round total.mb ...