查詢oracle 表空間剩餘(當前使用者具有dba許可權才可以)
select tablespace_name "表空間",
to_char(round(bytes / 1024, 2), '99990.00')
|| '' "實有",
to_char(round(free / 1024, 2), '99990.00')
|| 'g' "現有",
to_char(round(( bytes - free ) / 1024, 2), '99990.00')
|| 'g' "使用",
to_char(round(10000 * used / bytes) / 100, '99990.00')
|| '%' "比例"
from (select a.tablespace_name tablespace_name,
floor(a.bytes / ( 1024 * 1024 )) bytes,
floor(b.free / ( 1024 * 1024 )) free,
floor(( a.bytes - b.free ) / ( 1024 * 1024 )) used
from (select tablespace_name tablespace_name,
sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name tablespace_name,
sum(bytes) free
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name);
查詢表空間名稱,使用量
select
a.tablespace_name 表空間名稱,
total 總計,
total - free 已使用,
free 空閒,
round((total - free) / total * 100, 2) 使用佔比
from (
select tablespace_name
, round(sum(bytes) / 1024 / 1024) as total
from dba_data_files
group by tablespace_name
) aleft join (
select tablespace_name
, round(sum(bytes) / 1024 / 1024) as free
from dba_free_space
group by tablespace_name
) bon a.tablespace_name = b.tablespace_name
order by (total - free) / total desc;
查詢表空間檔案位置
select t1.name,t2.name from v$tablespace t1,v$datafile t2where t1.ts# = t2.ts#;
為表空間dataspace 新增乙個初始空間50m的可以自增長的資料檔案,最大可以到3200m
alter tablespace dataspace add datafile
'/u02/oradata/source/windinfo_14.dbf' size 50m
autoextend on next 50m maxsize 32000m;
Oracle查詢表空間與表大小
資料表的大小由段和區組成 當前使用者下的可以使用下面sql分別顯示段和區資訊 select us.segment name,us.bytes from user segments us order by us.bytes desc select from user extents ue order ...
ORACLE查詢每個表占用空間大小
select select sum bytes from dba segments where owner testbar and segment type table and segment name table name from user tables 錯誤的,對於oracle而言,雙引號 要...
Oracle表空間大小查詢和清理
統計表空間 select tablespace name 表空間,to char round bytes 1024,2 99990.00 實有,to char round free 1024,2 99990.00 g 現有,to char round bytes free 1024,2 99990....