修改oracle表空間

2021-06-20 00:47:54 字數 3270 閱讀 1082

修改oracle表空間

檢視表空間的位置

select a.tablespace_name,b.file_name,a.block_size,a.block_size,b.bytes/1024

/1024 "sum mb" from dba_tablespaces a,dba_data_files b where a.tablespace_name=b.tablespace_name;

檢視表空間是否自動增長:

select file_name,autoextensible,increment_by from dba_data_files;

檢視所有表空間大小情況:

select a.tablespace_name,a.bytes/1024/1024 "sum mb",(a.bytes-b.bytes)/1024/1024 "used mb",b.bytes/1024/1024 "free mb",round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"

from

(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,

(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b

where a.tablespace_name=b.tablespace_name

order by ((a.bytes-b.bytes)/a.bytes) desc

檢視datatbs01'的大小情況,以及空間檔案

select file_name,tablespace_name,bytes/1024/1024 "bytes mb",maxbytes/1024/1024 "maxbytes mb" from dba_data_files

where tablespace_name='datatbs01';

為datatbs01表空間增加,空間檔案 datatbs03.dbf   大小 20g

alter tablespace datatbs01

add datafile '/data/oracle/datatbs03.dbf'

size 10m autoextend on maxsize 20g

參考---------------------

檢視oracle表空間大小的方法

2011-11-09 13:23:47

分類: oracle

磁碟空間不足問題

我們經常會遇到,檢視oracle表空間大小就成了

我們必須要掌握的知識,讓

我們了解什麼時候需要增加表空間。

oracle表空間大小的檢視方法應該是

我們都需要掌握的知識,下面就為您詳細介紹檢視

oracle

表空間大小的方法,供您參考學習。

在資料庫管理中,磁碟空間不足是dba都會遇到的問題,問題比較常見。

--1檢視oracle表空間大小--已經使用的百分比。

select a.tablespace_name,a.bytes/1024/1024 "sum mb",(a.bytes-b.bytes)/1024/1024 "used mb",b.bytes/1024/1024 "free mb",round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"

from

(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,

(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b

where a.tablespace_name=b.tablespace_name

order by ((a.bytes-b.bytes)/a.bytes) desc

「sum mb」表示表空間所有的資料檔案總共在作業系統占用磁碟空間的大小

比如:test表空間有2個資料檔案,datafile1為300mb,datafile2為400mb,那麼test表空間的「sum mb」就是700mb

「userd mb」表示表空間已經使用了多少

「free mb」表示表空間剩餘多少

「percent_user」表示已經使用的百分比

--2比如從1中檢視到mlog_norm_space表空間已使用百分比達到90%以上,可以檢視該錶空間總共有幾個資料檔案,每個資料檔案是否自動擴充套件,可以自動擴充套件的最大值。

select file_name,tablespace_name,bytes/1024/1024 "bytes mb",maxbytes/1024/1024 "maxbytes mb" from dba_data_files

where tablespace_name='mlog_norm_space';

--3比如mlog_norm_space表空間目前的大小為19gb,但最大每個資料檔案只能為20gb,資料檔案快要寫滿,可以增加表空間的資料檔案

用作業系統unix、linux中的df -g命令(檢視下可以使用的磁碟空間大小)

獲取建立表空間的語句:

select dbms_metadata.get_ddl('tablespace','mlog_norm_space') from dual;

--4確認磁碟空間足夠,增加乙個資料檔案

alter tablespace mlog_norm_space

add datafile '/oracle/oms/oradata/mlog/mlog_norm_data001.dbf'

size 10m autoextend on maxsize 20g

--5驗證已經增加的資料檔案

select file_name,file_id,tablespace_name from dba_data_files

where tablespace_name='mlog_norm_space'    --注意表空間要大寫

--6如果刪除表空間資料檔案,如下:

alter tablespace mlog_norm_space

drop datafile '/oracle/oms/oradata/mlog/mlog_norm_data001.dbf'

Oracle建立修改表空間

今天在現場發現網路監控系統無論我怎麼配置都無法寫入資料到oracle資料庫中,後來一看錶空間使用率已超過了95 當初500m的表空間沒有設定自動擴充套件以及無大小限制,都是粗心惹的禍啊,下面是建立表空間以及修改表空間大小的sql語句,有興趣的童鞋可以看看。建立表空間 oracle10g 初始大小50...

Oracle修改表空間大小

使用oracle10g建立資料庫後,向資料庫中匯入了部分資料,第二天繼續向資料庫中匯入資料表時發生錯誤 org.hibernate.exception.genericjdbcexception ora 00604 遞迴 sql 級別 1 出現錯誤 ora 04031 無法分配 256 位元組的共享記...

Oracle修改表空間大小

問題描述 在向orale資料庫匯入資料的時候報 ora 01658 無法為表空間 中的段建立 initial 區錯誤。這是由於表空間對應的資料檔案中資料量超過oracle在建立表空間的時候資料檔案初始化大小值,當資料量達到這個值,再向資料庫中匯入資料就會報錯。解決方案 解決辦法就是擴充套件表空間,可...