檢視各表空間的使用情況

2021-08-25 01:32:50 字數 1489 閱讀 1045

今天要建庫倒表了,首先檢視資料庫各個表空間的情況:

select c.tablespace_name tablespace_name, round(a.bytes/1048576,2) total_size,round((a.bytes-b.bytes)/1048576,2) used_size,

round(b.bytes/1048576,2) free_size,

round(b.bytes/a.bytes * 100,2)||'%' free_pct from

(select tablespace_name,sum(a.bytes) bytes

from sys.dba_data_files a

group by tablespace_name) a,

(select a.tablespace_name,

nvl(sum(b.bytes),0) bytes

from sys.dba_data_files a,

sys.dba_free_space b

where a.tablespace_name = b.tablespace_name (+)

and a.file_id = b.file_id (+)

group by a.tablespace_name) b,

sys.dba_tablespaces c

where a.tablespace_name = b.tablespace_name(+)

and a.tablespace_name = c.tablespace_name

order by round(b.bytes/1048576,2);

沒有需要用到的表空間,所以建個新的:

create tablespace lnlt

logging

datafile 'e:\oracle\product\10.1.0\oradata\dblnlt\lnlt01.dbf'

size 1024m

autoextend on

next 100m maxsize 10240m

extent management local

然後在pl/sql develope中建立使用者。system privileges用的預設的,就是那個unlimited tablespace好像。role privileges 是connect 和 resource( resource好像已經不推薦使用了)。

現在準備倒表了,表檔案是以.sql結尾的檔案,別人提供的,怎麼匯出來的不清楚。

在 plsql develop中,選tools --> import tables,在彈出的視窗中可以看到,有三種匯入方式:"oracle import","sql inserts"和"pl/sql develop"。試了下,只有中間這種可以成功匯入,暫時不知道為什麼。哈哈。

檢視表空間使用情況

select upper a.tablespace name 表空間名 d.tot grootte mb 表空間大小 m d.tot grootte mb a.total bytes 已使用空間 m to char round d.tot grootte mb a.total bytes d.tot...

檢視表的空間使用情況

在 中,可以直接在表的屬性中看到表的大小和索引檔案大小,而後 中卻不能直接看到,需要用以下 來實現,其實o.name like 是用來篩選表的名字的 if not exists select from dbo.sysobjects where id object id n dbo tablespac...

檢視索引使用情況

檢視乙個索引是否正確建立,可以參考下這兩個引數 handler read key 和 handler read rnd next。如果索引正在工作,handler read key 的值將很高,這個值代表了乙個行被索引值讀取的次數,很低的值則表明增加索引得到的效能不高,因為索引並不經常使用。hand...