---
title: " 查看表空间 使用情况"
author: "jontan"
date: "2014-01-10T22:43:26Z"
tags: []
categories: ["数据库"]
slug: "untitled"
draft: false
lastmod: "2014-01-10T22:43:26Z"
id: 2002523
url: "https://summary.iteye.com/blog/2002523"
---

查看ORACLE数据库表空间 使用情况

```
    select distinct a.tablespace_name 表空间名称,
                   trunc(((total_space - free_space) / total_space) * 100) || '%' 已使用率,
                   (total_space - free_space) / 1024 / 1024 已使用空间,
                   to_char(free_space / 1024 / 1024, '9999999990.99') || 'M' 剩余空间,
                   total_space / 1024 / 1024 总空间
     from (select tablespace_name, sum(bytes) free_space
             from dba_free_space
            group by tablespace_name) a,
          (select tablespace_name, sum(bytes) total_space
             from dba_data_files
            group by tablespace_name) b
    where a.tablespace_name = b.tablespace_name;
```