--查看Oracle表空间Sql语句
--1.查看所有表空间大小
SELECT TABLESPACE_NAME,SUM(BYTES)/1024/1024 tablespacesize_M FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME;
--2.未使用的表空间大小
SELECT TABLESPACE_NAME,SUM(BYTES)/1024/1024 TABSPACE_FREE_SIZE_M FROM DBA_FREE_SPACE
group by TABLESPACE_NAME;
--3.所有使用空间可以这样计算
SELECT a.tablespace_name,a.total,b.free, a.total-b.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.下面这条语句查看所有段的大小
select segment_nam,sum(bytes)/1024/1024 from USER_EXTENTS GROUP BY segment_name;
--5.在命令行情况下如何将结果放到一个文件里 用到了telnet
SET TRIMSPOOL ON
SET LINESIZE 2000
SET PAGESIZE 2000
SET NEWPAGE 1
SET HEADING OFF
SET TERM OFF
SPOOL D:\EXP.TXT
SELECT * FROM V$DATABASE;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载