What are "versions" of an SQL statement?

解析了在Oracle中SQL语句如何被解析为不同版本的过程。当一个SQL语句被提交时,Oracle会根据多个因素判断其是否可以使用已有的执行计划,如数据库对象的一致性、初始化参数等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

refer: http://www.ixora.com.au/q+a/0010/27021816.htm

 

From:Steve Adams
Date:27-Oct-2000 03:18
Subject:  What are "versions" of an SQL statement?

I'm sure that I've answered this question before, but I cannot find the answer at the moment, so here it is again. Let us say that I want to parse the statement:

    select sum(discount) from sales where region = :1
Oracle will compute the hash value for this SQL statement and search the hash chain for that hash value via the library cache hash table looking for an existing cached SQL statement with exactly the same text. Before an execution plan for this statement prepared for another session can be shared however, Oracle has to check several things.

It has to make sure that this session is referring to the same database objects as the previous session - not objects of the same name in a different schema. The initialization parameters that influence the optimizer must match. The NLS environments must match. And finally, the types and lengths of bind variables must match.

If any of these checks fails, then Oracle regards it as a new version of the same statement and prepares a new execution plan. The existing version (or versions) are not discarded from the library cache, because it (they) might yet be reused by other sessions.

 

What do you mean by "many versions of a sharable SQL statement in the SQL AREA"?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值