1. 查看所有表空间大小
- select tablespace_name,sum(bytes)/1024/1024 from dba_data_files
- roup by tablespace_name;
2. 未使用的表空间大小
- select tablespace_name,sum(bytes)/1024/1024 from dba_free_space
- group by tablespace_name;
3. 所以使用空间可以这样计算
- select a.tablespace_name,total,free,total-free used from
- ( select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files
- group by tablespace_name) a,
- ( select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space
- group by tablespace_name) b
- where a.tablespace_name=b.tablespace_name;
4. 下面这条语句查看所有segment的大小。
- Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name
5. 还有在命令行情况下如何将结果放到一个文件里。
- SQL> spool out.txt
- SQL> select * from v$database;
- SQL> spool off
6.如何查看oracle临时表空间当前使用了多少空间的大小?
不是占用量,是当前正在使用的临时表空间大小
- SELECT SE.USERNAME,
- SE.SID,
- SU.EXTENTS,
- SU.BLOCKS * TO_NUMBER(RTRIM(P.VALUE)) AS SPACE,
- TABLESPACE,
- SEGTYPE,
- SQL_TEXT
- FROM V$SORT_USAGE SU, V$PARAMETER P, V$SESSION SE, V$SQL S
- WHERE P.NAME = 'db_block_size'
- AND SU.SESSION_ADDR = SE.SADDR
- AND S.HASH_VALUE = SU.SQLHASH
- AND S.ADDRESS = SU.SQLADDR
- ORDER BY SE.USERNAME, SE.SID;
查询所有的表空间
- select tablespace_name from dba_tablespaces
查看表空间中分布的用户信息
- select tablespace_name, owner,sum(bytes) from dba_segments
- group by tablespace_name, owner