ITPub博客

首页 > 数据库 > Oracle > [20251027]建立完善s2h.sql脚本.txt

[20251027]建立完善s2h.sql脚本.txt

原创 Oracle 作者:lfree 时间:2025-11-01 20:52:45 0 删除 编辑

[20251027]建立完善s2h.sql脚本.txt

--//增加kgl_bucket的计算。

$ cat s2h.sql
-- Copyright 2023 lfree. All rights reserved.
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms and conditions.
----------------------------------------------------------------------------------------------
--
-- Name:        s2h.sql
-- Purpose:     display Sql_id of Hash_value
--
-- Author:      lfree
-- Usage:
--     @ s2h <sql_id>
--
-----------------------------------------------------------------------------------------------
column sql_id format a13
column hash_value format 9999999999

SELECT '&1' sql_id
      ,DBMS_UTILITY.SQLID_TO_SQLHASH ('&1') hash_value
      ,MOD (DBMS_UTILITY.SQLID_TO_SQLHASH ('&1'), 131072) kgl_bucket
  FROM DUAL;


SCOTT@book01p> @ sql_id 318q0cyx1n9s3

-- SQL_ID = 318q0cyx1n9s3 come from shared pool

Select /*+ a */ count(*) from t1 where id = :"SYS_B_0";

SCOTT@book01p> @ s2h 318q0cyx1n9s3

SQL_ID         HASH_VALUE KGL_BUCKET
------------- ----------- ----------
318q0cyx1n9s3  3122276099       9987


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3099453/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969348