ORACLE数据库新增表空间的数据存储文件

 随着时间的推移,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

相关文章
相关标签/搜索