oracle查询表空间的空间占用情况
select a.tablespace_name,a.bytes bytes_used,b.largest,round(((a.bytes - b.bytes)/a.bytes)*,) 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 查询所有表空间的总容量、已经使用、剩余、已经使用的百分比! select a.tablespace_name,a.bytes// "Sum MB",(a.bytes-b.bytes)// "used MB",b.bytes// "free MB",
round(((a.bytes-b.bytes)/a.bytes)*,) "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 一般来说可以把上面的复杂的查询语句放入一个文件中,需要时再调用,或者创建一个试图,需要时可以查询。
写入文件:#vi /home/mzl/percent_used_tablespace.sql
内容:
select a.tablespace_name,a.bytes// "Sum MB",(a.bytes-b.bytes)// "used MB",b.bytes// "free MB",
round(((a.bytes-b.bytes)/a.bytes)*,) "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 导入:
SQL> @/home/mzl/percent_used_tablespace.sql
SQL> l
select a.tablespace_name,a.bytes "Sum",a.bytes-b.bytes "used",b.bytes "free",
round(((a.bytes-b.bytes)/a.bytes)*,) "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
SQL> / 或者创建视图:
create view percent
as
select a.tablespace_name,a.bytes// "Sum MB",(a.bytes-b.bytes)// "used MB",b.bytes// "free MB",
round(((a.bytes-b.bytes)/a.bytes)*,) "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; SQL> select * from percent; 查看表空间的数据文件是否是自动扩展:
SQL> select file_name,tablespace_name,autoextensible from dba_data_files FILE_NAME TABLESPACE_NAME AUT
--------------------------------------------- ------------------------------ ---
/u01/app/oracle/oradata/orcl/risenet.dbf RISENET
/u01/app/oracle/oradata/orcl/perfstat.dbf PERFSTAT NO
/u01/app/oracle/oradata/orcl/example01.dbf EXAMPLE YES
/u01/disk1/users01.dbf USERS YES
/u01/app/oracle/oradata/orcl/sysaux01.dbf SYSAUX YES
/u01/app/oracle/oradata/orcl/undotbs01.dbf UNDOTBS1
/u01/disk2/system01.dbf SYSTEM YES
/u01/app/oracle/oradata/orcl/undotbs02.dbf UNDOTBS2 NO
/u01/disk1/pioneer_data.dbf PIONEER_DATA YES
/u01/disk2/pioneer_indx.dbf PIONEER_INDX NO
/u01/disk3/pioneer_undo.dbf PIONEER_UNDO NO FILE_NAME TABLESPACE_NAME AUT
--------------------------------------------- ------------------------------ ---
/u01/app/oracle/oradata/orcl/paul01.dbf PAUL NO
/u01/disk1/wenchuan.dbf WENCHUAN NO rows selected. 比如表空间PIONEER_INDX已经用了83.%,数据文件不能自动扩展,可以修改成自动扩展,以免数据写满数据文件。 SQL> alter database datafile '/u01/disk2/pioneer_indx.dbf' autoextend on; Database altered. SQL> select file_name,tablespace_name,autoextensible from dba_data_files where tablespace_name='PIONEER_INDX'; FILE_NAME TABLESPACE_NAME AUT
--------------------------------------------- ------------------------------ ---
/u01/disk2/pioneer_indx.dbf PIONEER_INDX YES 或者给表空间多加一个自动扩展的数据文件,如果有多个硬盘,可以增加多个数据文件(这样多数据库系统的并发性比较好)
SQL> alter tablespace pioneer_indx add datafile size 30M; Tablespace altered. SQL> select file_name,tablespace_name,bytes// "MB"
from dba_data_files
where tablespace_name='PIONEER_INDX';
oracle查询表空间的空间占用情况的更多相关文章
- 在Oracle中查询表的大小、表的占用情况和表空间的大小
转载自http://blog.csdn.net/cuker919/article/details/8514253 select segment_name, bytes as 大小 from user_ ...
- Oracle中查询表的大小、表的占用情况和表空间的大小
有两种含义的表大小.一种是分配给一个表的物理空间数量,而不管空间是否被使用.可以这样查询获得字节数: select segment_name, bytes from user_segments whe ...
- oracle 查询表的大小,表空间的使用情况,默认表空间
oracle 查询表的大小,表空间的使用情况,默认表空间 oracle 查询表的大小,表空间的使用情况,默认表空间 --查看某张表占用磁盘空间大小 ( 表名大写 ) Select Segment_Na ...
- linux系统下oracle表空间占用情况
1.我们先查询表空间的占用情况,使用sql如下: select upper(f.tablespace_name) "表空间名", d.tot_grootte_mb "表空 ...
- Oracle查询表空间使用率很慢
Oracle查询表空间使用率很慢 问题描述 执行查询表空间的语句,需要接近2min的时间才能执行完成. 以前也在其他客户的生产库遇到过一样的情况,当时是由于回收站的内容过多引起的. 不过这次的情况却不 ...
- 简单统计SQLSERVER用户数据表大小(包括记录总数和空间占用情况)
在SQLSERVER,简单的组合sp_spaceused和sp_MSforeachtable这两个存储过程,可以方便的统计出用户数据表的大小,包括记录总数和空间占用情况,非常实用,在SqlServer ...
- Linux 命令 - df: 报告磁盘空间的占用情况
df 命令列出指定的文件名所在的文件系统上可用磁盘空间的数量. 如果没有指定文件名,则显示当前所有使用中的文件系统.默认情况下,磁盘空间以 1K 为一块显示,如果设置了环境变量 POSIXLY_COR ...
- Linux:查看磁盘空间占用情况
Linux:查看磁盘空间占用情况 工作中有时被分配的测试机空间不大,经常遇到磁盘空间占满的情况.排查过程如下: 一.首先使用df -h 命令查看磁盘剩余空间,通过以下图看出/目录下的磁盘空间已经被占满 ...
- [转帖]Oracle 查询各表空间使用情况--完善篇
Oracle 查询各表空间使用情况--完善篇 链接:http://blog.itpub.net/28602568/viewspace-1770577/ 标题: Oracle 查询各表空间使用情况--完 ...
- Oracle查看所有表空间的数据使用情况
-- 查看所有表空间的数据使用情况 SELECT Upper(F.TABLESPACE_NAME) "表空间名", D.TOT_GROOTTE_MB "表空间大小(M)& ...
随机推荐
- python之对象回收机制
python中,当程序执行完毕之后,python的垃圾回收机制就会将所有对象回收,清除占用的内存 请看如下代码 class Parent(): def __init__(self,name): sel ...
- Shell水平测试-想学习Shell的童鞋必选必看文章
[SHELL水平测试] [OVERVIEW 篇] 有很多种 shell, 你熟悉几种? 各个 shell 的 home page 在那里? 为什么说 zsh 是目前为止功能最为强大的 shell. 为 ...
- 安装k8s和NVIDIA环境
安装环境 系统要求 CPU: 2个核心 内存: 2GB 显卡:NVIDIA系列 安装docker apt install docker.io 安装k8s 添加软件源 方便起见,将Ubuntu的软件管理 ...
- cogs 619. [金陵中学2007] 传话 Tarjan强连通分量
619. [金陵中学2007] 传话 ★★ 输入文件:messagez.in 输出文件:messagez.out 简单对比时间限制:1 s 内存限制:128 MB [问题描述] 兴趣小 ...
- MySQL 行列相互转换
行列相互转换 /*创建表*/ CREATE TABLE ic ( NAME ), Product ), amount INT ); INSERT INTO ic VALUES (), (), (), ...
- 【智能合约】编写复杂业务场景下的智能合约——可升级的智能合约设计模式(附Demo)
智能合约的现状 以太坊在区块链上实现了智能合约的概念,用于:同质化通证发行(ERC-20).众筹.投票.存证取证等等,共同点是:合约逻辑简单,只是业务流程中的关键节点,而非整个业务流程.而智能合约想解 ...
- MTV
M:模型 models.py T:模板 html C:控制 urls.py 和 views.py 与MVC类似
- spring Cloud-eureka的保护模式
eureka的首页出现以下警告 EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. REN ...
- 关于C#程序的单元测试
目录 1.单元测试概念 2.单元测试的原则 3.单元测试简单示例 4.单元测试框架特性标签 5.单元测试中的断言Assert 6.单元测试中验证预期的异常 7.单元测试中针对状态的间接测试 8.单元测 ...
- [ PyQt入门教程 ] PyQt5中多线程模块QThread使用方法
本文主要讲解使用多线程模块QThread解决PyQt界面程序唉执行耗时操作时,程序卡顿出现的无响应以及界面输出无法实时显示的问题.用户使用工具过程中出现这些问题时会误以为程序出错,从而把程序关闭.这样 ...