檢視資料庫建立了哪些表空間oracle

時間 2021-08-11 18:15:19

1樓:匿名使用者

檢視oracle中表空間需要用具有dba許可權的使用者使用以下語句:

select distinct tablespace_name from dba_data_files;

查詢結果:

另外,可通過其他方法檢視一下oracle中表空間的使用率,語句如下:

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

order by used_pct desc;

查詢結果:

2樓:杜爺1號

select table_name ,tablespace_name from dba_tables where tablespace_name = '表空間名';

需要dba許可權

select table_name ,tablespace_name from user_tables where tablespace_name = '表空間名';

只查當前使用者的不需dba許可權。

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

3樓:匿名使用者

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;

輸出結果為:

4樓:匿名使用者

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

select tablespace_name from dba_tablespaces;

表空間含義:

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

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

5樓:匿名使用者

很簡單,查 dba_tablespaces 資料字典:

select tablespace_name from dba_tablespaces;

6樓:匿名使用者

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

7樓:匿名使用者

select distinct tablespace_name from dba_data_files;

select distinct tablespace_name from dba_temp_files;

怎樣查詢oracle資料庫中所有的表空間

8樓:匿名使用者

oracle中查詢當前資料庫中的所有表空間和對應的資料檔案語句命令

1、在cmd中輸入sqlplus,彈出命令列窗體

2、輸入口令和密碼

3、sql>col file_name for a60;

4、sql>set linesize 160;

5、sql>select file_name,tablespace_name,bytes from dba_data_files;

同樣的可以從dba_temp_files資料字典中查詢臨時表空間的資訊

sql>select tablespace_name,file_name from dba_temp_files;

刪除oracle表空間與表空間檔案語句如下:

sql>drop tablespace 表空間名稱 including contents and datafiles ;

示例:--刪除oracle表空間和檔案的語句命令

drop tablespace 表空間名稱 including contents and datafiles cascade constraints;

--including contents 刪除表空間中的內容

--datafiles 刪除表空間中的資料檔案

--cascade constraints 刪除所有與表空間資料有關的級聯,如主外來鍵等

oracle 怎麼檢視一個資料庫中有幾個表空間?以及這些表空間的名字?

9樓:穀梁秀梅接霜

檢視錶空間名字

select

distinct

tablespace_name

from

tabs

檢視幾個表空間

select

count(distinct

tablespace_name)

from

tabs

我是偷學的,哈哈

oracle 怎麼檢視一個資料庫中有幾個表空間

10樓:匿名使用者

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;

sql server預設建立了哪些資料庫這些資料庫的作用

master資料庫 記錄系統級別資訊。例如 登入賬戶 系統配置設定 資料庫的位置 sql server初始化資訊等。tempdb資料庫 儲存臨時表和臨時儲存過程。例如 資料排序建立臨時表 資料篩選建立臨時表等。model資料庫 用於在系統上建立的所有資料庫的模板。例如 用sql語句建立一個空白資料庫...

oracle資料庫建立表空間出現錯誤ora 01917 ora

從你的sqlplus中看你是在建立user,再grant許可權。而不是建立表空間。你連概念都分不清還怎麼做。另外,建立物件的時候如果使用雙引號,是區分大小寫的。oracle預設是不區分大小寫 這是報錯使用者不存在,沒許可權。必須用dba許可權操作的。建立表空間 create tablespace t...

mysql資料庫怎樣建立表,MYsql資料庫怎樣建立表?

歐覓潘安然 比如要建立學生表表名為student,學生表有欄位學號 no 年齡 age create table student no int primary key 主鍵 age int 執行下就建立好了 隨便舉的例子,明白吧?謝謝採納! create database cookbook 建立一個...