【ORACLE】 表空间信息

Linux 查看磁盘空间命令
格式: df -hl

显示格式为:

文件系统 容量 已用 可用 已用% 挂载点

[root@localhost opt]# df
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sda3      416502068 103330280 313171788  25% /
devtmpfs         1899236         0   1899236   0% /dev
tmpfs            1907804         0   1907804   0% /dev/shm
tmpfs            1907804      9056   1898748   1% /run
tmpfs            1907804         0   1907804   0% /sys/fs/cgroup
/dev/sda1       51175000  51164908     10092 100% /home
tmpfs             381564         8    381556   1% /run/user/42
tmpfs             381564         0    381564   0% /run/user/1001
tmpfs             381564         0    381564   0% /run/user/0
其中
/dev/sda1       51175000  51164908     10092 100% /home 可见  /home 使用已经100%
 
表空间信息可以通过以下脚本查询:
 
select a.tablespace_name 表空间,
       c.file_name 表空间数据文件,
       c.bytes / 1024 / 1024 || 'M' 该数据文件大小,
       a.total_bytes || 'M' 总计,
       a.total_bytes - nvl(b.free_bytes, 0) || 'M' 已使用,
       round((a.total_bytes - nvl(b.free_bytes, 0)) / a.total_bytes, 4) * 100 || '%' 表空间已使用百分比,
       nvl(b.free_bytes, 0) || 'M' 表空间剩余,
       round(nvl(b.free_bytes, 0) / a.total_bytes, 4) * 100 || '%' 表空间剩余百分比
  from (select df.tablespace_name, sum(df.bytes) / 1024 / 1024 Total_bytes
          from dba_data_files df
         group by df.tablespace_name) a,
       (select fs.tablespace_name, sum(fs.bytes) / 1024 / 1024 Free_bytes
          from dba_free_space fs
         group by fs.tablespace_name) b,
       dba_data_files c
 where a.tablespace_name = b.tablespace_name(+)
   and a.tablespace_name = c.tablespace_name
 order by a.total_bytes desc
 
如果磁盘空间足够大,可以通过自动扩展表空间的方法扩大表空间
alter database datafile 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_1\DATABASE\PRMMS_GIS2' autoextend on;
 
如果磁盘空间不足,可以通过增加表空间文件的方法再其他磁盘创建表空间文件扩展表空间 
alter tablespace TBLSMS add datafile '/opt/oracle/oradata/starboss/tblsms.dbf' size 5000M autoextend on maxsize 20G;

 
 
posted @ 2016-04-25 23:16  不及格的飞鱼  阅读(193)  评论(0编辑  收藏  举报