隨着時間的推移,oracle表空間的容量逐漸減小,最後會出現空間不足的狀況, 這個時候就須要咱們手動建立表空間的數據存儲文件。
1. 查看oracle數據庫全部表空間的名字、 總容量、 剩餘容量。
sql
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
2. 查看指定表空間的文件目錄和空間使用狀況。數據庫
select file_name, tablespace_name, bytes/1024/1024 "bytes MB", maxbytes/1024/1024 "maxbytes MB" from dba_data_files where tablespace_name='TBS_MSADEN_01';
其中'TBS_MSADEN_01'爲oracle數據庫中存在的表空間。oracle
3. 爲指定表空間建立新的數據存儲文件。
spa
alter tablespace TBS_MSADEN_01 add datafile '/msaden/oracledata/TBS_MSADEN_01.dbf' size 10M autoextend on maxsize 20G
其中TBS_MSADEN_01 爲表空間名稱,'/msaden/oracledata/TBS_MSADEN_01.dbf' 爲表空間數據存儲文件地址, 該數據存儲文件初始化大小爲10M, 自動增加, 最大爲20G.
code