名站网址导航为大家提供关于数据库教程相关的教程网站知识。
这篇文章主要介绍了Oracle中查看表空间使用率的SQL脚本分享,本文直接给出脚本具体相关代码和运行效果图,需要的朋友可以参考下Oracle中查看引起Session阻塞的2个脚本分享
用户A执行删除,但是没有提交。, , ,已删除8行。,用户B执行删除或者更新id<10的记录,则被阻塞。, , ,遇到这种阻塞,首先需要确定问题。可以使用以下脚本。, , ,结果如下:, , ,或者使用, , ,结果如下:, , ,Kill引起阻塞的Session, , ,结果如下:, , ,最后执行alter system开始执行命令,阻塞解除。
复制具体相关代码具体相关代码如下:
/* Formatted on 2012/5/31 14:51:13 (QP5 v5.185.11230.41888) */
SELECT D.TABLESPACE_NAME,
SPACE || 'M' "SUM_SPACE(M)",
BLOCKS "SUM_BLOCKS",
SPACE - NVL (FREE_SPACE, 0) || 'M' "USED_SPACE(M)",
ROUND ( (1 - NVL (FREE_SPACE, 0) / SPACE) * 100, 2) || '%'
"USED_RATE(%)",
FREE_SPACE || 'M' "FREE_SPACE(M)"
FROM ( SELECT TABLESPACE_NAME,
ROUND (SUM (BYTES) / (1024 * 1024), 2) SPACE,
SUM (BLOCKS) BLOCKS
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) D,
( SELECT TABLESPACE_NAME,
ROUND (SUM (BYTES) / (1024 * 1024), 2) FREE_SPACE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F
WhERE D.TABLESPACE_NAME = F.TABLESPACE_NAME( )
UNION ALL --假如如果有临时表空间
SELECT D.TABLESPACE_NAME,
SPACE || 'M' "SUM_SPACE(M)",
BLOCKS SUM_BLOCKS,
USED_SPACE || 'M' "USED_SPACE(M)",
ROUND (NVL (USED_SPACE, 0) / SPACE * 100, 2) || '%' "USED_RATE(%)",
NVL (FREE_SPACE, 0) || 'M' "FREE_SPACE(M)"
FROM ( SELECT TABLESPACE_NAME,
ROUND (SUM (BYTES) / (1024 * 1024), 2) SPACE,
SUM (BLOCKS) BLOCKS
FROM DBA_TEMP_FILES
GROUP BY TABLESPACE_NAME) D,
( SELECT TABLESPACE_NAME,
ROUND (SUM (BYTES_USED) / (1024 * 1024), 2) USED_SPACE,
ROUND (SUM (BYTES_FREE) / (1024 * 1024), 2) FREE_SPACE
FROM V$TEMP_SPACE_hEADER
GROUP BY TABLESPACE_NAME) F
WhERE D.TABLESPACE_NAME = F.TABLESPACE_NAME( )
ORDER BY 1;
效果如下:
关于数据库教程相关的教程网站知识今天我们就说到这里了,希望可以帮到大家。