Home > Database > Mysql Tutorial > 数据库表空间信息查询

数据库表空间信息查询

WBOY
Release: 2016-06-07 14:53:45
Original
1442 people have browsed it

数据库表空间信息查询 --查看表空间的名称及大小 www.2cto.com SELECT T.TABLESPACE_NAME, ROUND(SUM(D.BYTES / (1024 * 1024)), 0) TS_SIZE FROM DBA_TABLESPACES T, DBA_DATA_FILES D WHERE T.TABLESPACE_NAME = D.TABLESPACE_NAME GROUPBY T.TABLESPACE_N


数据库表空间信息查询

 

--查看表空间的名称及大小  www.2cto.com  

SELECT T.TABLESPACE_NAME, ROUND(SUM(D.BYTES / (1024 * 1024)), 0) TS_SIZE

FROM DBA_TABLESPACES T, DBA_DATA_FILES D

WHERE T.TABLESPACE_NAME = D.TABLESPACE_NAME

GROUPBY T.TABLESPACE_NAME

 

--查看表空间物理文件的名称及大小

SELECT TABLESPACE_NAME, FILE_ID, FILE_NAME, ROUND(BYTES / (1024 * 1024), 0) TOTAL_SPACE

FROM DBA_DATA_FILES

ORDERBY TABLESPACE_NAME;

 

--表空间的未用空间

SELECT TABLESPACE_NAME, SUM(BYTES) / (1024 * 1024) MBYTES

FROM DBA_FREE_SPACE

GROUPBY TABLESPACE_NAME;

 

--数据库的大小,和空间使用情况

SELECT A.TABLESPACE_NAME, A.BYTES TOTAL, B.BYTES USED, C.BYTES FREE,

  (B.BYTES * 100) / A.BYTES "USED %", (C.BYTES * 100) / A.BYTES "FREE %"

FROMSYS.SM$TS_AVAIL A, SYS.SM$TS_USED B, SYS.SM$TS_FREE C

WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME AND A.TABLESPACE_NAME = C.TABLESPACE_NAME

 

--表空间的文件使用情况

SELECT B.FILE_ID 文件ID, B.TABLESPACE_NAME 表空间, B.FILE_NAME 物理文件名,

  B.BYTES 总字节数, (B.BYTES - SUM(NVL(A.BYTES, 0))) 已使用, SUM(NVL(A.BYTES, 0)) 剩余,

  SUM(NVL(A.BYTES, 0)) / (B.BYTES) * 100剩余百分比

FROM DBA_FREE_SPACE A, DBA_DATA_FILES B   

WHERE A.FILE_ID = B.FILE_ID   

GROUPBY B.TABLESPACE_NAME, B.FILE_NAME, B.FILE_ID, B.BYTES   

ORDERBY B.TABLESPACE_NAME   

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template