---
title: "查询Oracle表空间的使用情况"
author: "SunRuing"
date: "2012-05-12T22:26:49Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2012-05-30T13:44:07Z"
id: 1525816
url: "https://sunruing.iteye.com/blog/1525816"
---

select a.tablespace_name,a.all_bytes/1024/1024 "总大小(M)" ,b.free_bytes/1024/1024 "剩余大小(M)",
       round(((a.all_bytes - b.free_bytes)/a.all_bytes),3)*100 "使用百分比",round((b.free_bytes/a.all_bytes),3)*100 "剩余百分比" 
from 

( select  tablespace_name,sum(bytes) all_bytes from dba_data_files group by tablespace_name ) a,

( select tablespace_name,sum(bytes) free_bytes from dba_free_space group by tablespace_name )  b

where a.tablespace_name = b.tablespace_name;



spool  spool_read.txt;
set colsep '|';
set echo on;
set timing on;
set heading on;
set pagesize 0;
set termout on;
set trimout on;
set trimspool on;
set linesize 80;
select msisdn from table_name ;
spool off;
exit;

