直接查出Oracle資料庫的大小,查出所有表空間後再求和,謝

2021-04-30 06:40:38 字數 2335 閱讀 7077

1樓:司馬鑄劍

檢視所有表空間使用情況 :

select

b.file_id 檔案id號,

b.tablespace_name 表空間名,

b.bytes/1024/1024||'m'位元組數,

(b.bytes-sum(nvl(a.bytes,0)))/1024/1024||'m' 已使用,

sum(nvl(a.bytes,0))/1024/1024||'m' 剩餘空間,

100 - sum(nvl(a.bytes,0))/(b.bytes)*100 占用百分比

from dba_free_space a,dba_data_files b

where a.file_id=b.file_id

group by b.tablespace_name,b.file_id,b.bytes

order by b.file_id;

備註:建議用系統管理員dba許可權進行檢視。

oracle怎麼查詢所有的表空間的名稱?

2樓:匿名使用者

oracle資料庫中,查詢素有表空間的名稱只需要一條sql語句即可:

select tablespace_name  from user_tablespaces;

結果輸出如下圖:

在上式的sql中,「user_tablespaces」即為表空間資訊所在表,所需的表空間資訊需要從該表中獲取,「tablespace_name」即為表空間名稱,

select * from user_tablespaces;

結果輸出如下:

擴充套件資料:

針對表空間,還有其他的查詢可供參考:

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;

輸出結果如下:

2、檢視表空間物理檔案的名稱及大小

select tablespace_name, file_id, file_name, round(bytes / (1024 * 1024), 0) total_space

from dba_data_files order by tablespace_name;

輸出結果為:

3、查詢當前使用者所有表名及其所屬表空間

select table_name 表名 ,tablespace_name 所使用表空間 from user_tables;

輸出結果為:

3樓:匿名使用者

只查詢名字的話用如下語句:

select tablespace_name from dba_tablespaces;

表空間含義:

表空間是資料庫的邏輯劃分,乙個表空間只能屬於乙個資料庫。所有的資料庫物件都存放在指定的表空間中。但主要存放的是表, 所以稱作表空間。

oracle資料庫中至少存在乙個表空間,即system的表空間。

4樓:匿名使用者

很簡單,查 dba_tablespaces 資料字典:

select tablespace_name from dba_tablespaces;

5樓:匿名使用者

select

b.file_name 物理檔名,

b.tablespace_name 表空間,

b.bytes/1024/1024 大小m,

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

substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) 利用率

from dba_free_space a,dba_data_files b

where a.file_id=b.file_id

group by b.tablespace_name,b.file_name,b.bytes

order by b.tablespace_name

6樓:匿名使用者

select distinct tablespace_name from dba_data_files;

select distinct tablespace_name from dba_temp_files;

oracle資料庫如何刪除資料庫

操作步驟如下 第一步 用超級管理員登陸oracle conn as sysdbaconn as sysdba 第二步 刪除指定的使用者 drop user username cascade 第三步 重新建立此使用者 create user username identified by passwor...

oracle資料庫面試題,ORACLE資料庫面試題

1 update t set logdate 2003 01 01 where logdate 2001 02 11 2 select from t where rowid not in select max rowid from t group by id,name,address,phone,l...

oracle資料庫中資料庫和表空間是等同的嗎

不等同。簡單的說,資料庫是乙個整體,乙個資料庫下可保護多個使用者 多個表 多個儲存過程 多個job 多個檢視等。而表空間可以認為是資料實體檔案的分類,比如有使用者表空間 系統表空間 索引表空間等,乙個表空間可以保護多個實體檔案。可以設定表空間的儲存大小,但實際使用多少由已存在的資料來決定。比如設定使...