oracle檢視表空間使用率及擴容

2021-09-10 07:23:05 字數 1896 閱讀 8367

oracle表空間使用率檢視,首先登入,sysdba使用者,

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)

--where tablespace_name like 'cdr%' --這一句用於指定表空間名稱

查詢表空間儲存路徑

select b.file_id  檔案id,

b.tablespace_name  表空間,

b.file_name     物理檔名,

b.bytes       總位元組數,

(b.bytes-sum(nvl(a.bytes,0)))   已使用,

sum(nvl(a.bytes,0))        剩餘,

sum(nvl(a.bytes,0))/(b.bytes)*100 剩餘百分比

表空間擴容:

1.手動增加

alter tablespace szrxtest_data add datafile

2.允許已存在的檔案自增長

autoextend on next 100m maxsize 20480m;

ORACLE檢視表空間使用率

之前寫程式需要實現乙個查詢資料庫表空間使用率的功能,雖然不知道做它的意義有多大,專案要求就得做。寫了乙個,只能查到永久表空間,temp表空間不知道怎麼查詢,今天上網找了找,把sql補充完整了,其實都是找來現有的資源用的,收藏一下。select from select a.tablespace nam...

Oracle 檢視表空間使用率 SQL 指令碼

sql 語句 formatted on 2012 5 31 14 51 13 qp5 v5.185.11230.41888 select d.tablespace name,space m sum space m blocks sum blocks space nvl free space,0 m ...

檢視 Oracle 表空間使用率

1 用到了 sys.dba free space sys.dba data files 兩個檢視,需要被賦予在這兩個檢視物件上的查詢許可權。connect as sysdba grant select on sys.dba free space to forrest grant select on ...