MOP 系列|MOP 三种主流数据库常用 SQL(一)

2024年 4月 30日 49.1k 0

前 言

MOP 不用多说,指的就是 MySQL、Oracle、PostgreSQL 三种目前最主流的数据库,MOP 系列打算更新 MOP 三种数据库的索引知识、高可用架构及常用 SQL 语句等等,上面已经更新了 MOP 索引相关的文章,今天打算整理一下这三种数据库的常用 SQL 知识,但由于文章过长,今天分享 Oracle 篇。

Oracle 常用 SQL 大全

作者:JiekeXu
来源 | JiekeXu DBA 之路(ID: JiekeXu_IT)
转载请联系授权 | (微信 ID:JiekeXu_DBA)

SQL 大全一 https://www.modb.pro/doc/22598
SQL 大全二 https://www.modb.pro/db/45337
SQL 大全三 https://www.modb.pro/doc/91589
SQL 大全四 https://www.modb.pro/doc/103483
Oracle DBA 日常维护 SQL 脚本大全(收藏版) https://www.modb.pro/db/44364

本文 SQL 均是在运维工作中总结整理而成的,非个人独创,部分 SQL 来源于互联网,但现在已经不知道具体是来源哪个网站、哪个人,如有侵权,可联系我及时删除,谢谢!

按 Buffer Gets 降序排列 TOP SQL

set linesize 150
set pagesize 100
col sql_text form a50
SELECT * FROM
(SELECT SQL_ID,substr(sql_text,1,50) sql_text,trunc(ELAPSED_TIME/executions) ELAPSED_TIME_PER,
executions,buffer_gets,trunc(buffer_gets/executions) gets_per
FROM V$SQLSTATS
WHERE buffer_gets > 10000 and executions0
ORDER BY buffer_gets DESC)
WHERE rownum 100 and executions0
ORDER BY executions DESC)
WHERE rownum 100 and executions0
ORDER BY parse_calls DESC)
WHERE rownum 1000 and executions0
ORDER BY disk_reads DESC)
WHERE rownum 1048576 and executions0
ORDER BY sharable_mem DESC)
WHERE rownum 100 and executions0
ORDER BY gets_per DESC)
WHERE rownum 0;

--原文链接:https://blog.csdn.net/robinson1988/article/details/106204387

select distinct 'ALTER SYSTEM KILL SESSION ' || '''' || sid || ',' || serial# || ',@' || inst_id || '''' ||' IMMEDIATE;'
from (select a.inst_id, a.sid, a.serial#,
a.sql_id,
a.event,
a.status,
connect_by_isleaf as isleaf,
sys_connect_by_path(a.SID||'@'||a.inst_id, '

相关文章

pt-kill工具的使用
pt-ioprofile工具包的使用
数据库管理-第216期 Oracle的高可用-01(20240703)
DBMS_REPAIR EXAMPLE SCRIPT WITH PARTITION
数据库事务的四大特性: ACID 
使用BBED修复损坏的SYSTEM文件头

发布评论