Oracle必備語句

2021-06-20 18:05:11 字數 1772 閱讀 6389

select upper(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 by tablespace_name) f,

(select dd.tablespace_name,

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

from sys.dba_data_files dd

group by dd.tablespace_name) d

where d.tablespace_name = f.tablespace_name

order by 1;

--查詢表空間的free space

select tablespace_name,

count(*) as extends,

round(sum(bytes) / 1024 / 1024, 2) as mb,

sum(blocks) as blocks

from dba_free_space

group by tablespace_name;

--查詢表空間的總容量

select tablespace_name, sum(bytes) / 1024 / 1024 as mb

from dba_data_files

group by tablespace_name;

--查詢表空間使用率

select total.tablespace_name,

round(total.mb, 2) as total_mb,

考試大論壇

round(total.mb - free.mb, 2) as used_mb,

round((1 - free.mb / total.mb) * 100, 2) || '%' as used_pct

from (select tablespace_name, sum(bytes) / 1024 / 1024 as mb

from dba_free_space

group by tablespace_name) free,

(select tablespace_name, sum(bytes) / 1024 / 1024 as mb

from dba_data_files

group by tablespace_name) total

where free.tablespace_name = total.tablespace_name;

Oracle入門必備函式

我的學習總結 1 資料庫基本是有表,關係,操作組成的。2 sql 結構化查詢語言 根據操作目的分為ddl 資料定義語言 dml 資料操縱語言 dcl 資料控制語言 3 刪了 4 char 字串以定長字串的形式儲存在指定為char型的列中。所謂定長字串,就是當列中儲存的字串長度達不到最大長度時,使用半...

Oracle 必備知識點

sql alter user scott identified by mypassword sql alter user scott account unlock 作業系統認證,不需要資料庫伺服器啟動listener,也不需要資料庫伺服器處於可用狀態。比如我們想要啟動資料庫就可以用這種方式進入sql...

oracle 語句轉mysql語句

oracle to date 06 08 2019 16 20 50 dd mm yyyy hh24 mi ss mysql str to date 06 08 2019 16 20 50 d m y h i s mysql 類似to char to date 函式 mysql日期和字元相互轉換方法...