3個視圖(v$sql、v$sqltext、V$SQLAREA)的區別

3個視圖(v$sql、v$sqltext、V$SQLAREA)的區別

準備從下面幾個方面去查看

a.        從官方文檔找到視圖的定義描述及視圖的結構和字段信息

b.       根據v$fixed_view_definition視圖找出題目原始的定義區別

c.        根據上面2點的推測,做測試驗證

 

第一:從官方文檔入手:

V$SQLTEXT

This view contains the text of SQL statements belonging to shared SQL cursors in the SGA.

Column

Datatype

Description

ADDRESS

RAW(4 | 8)

Used with HASH_VALUE to uniquely identify a cached cursor

HASH_VALUE

NUMBER

Used with ADDRESS to uniquely identify a cached cursor

SQL_ID

VARCHAR2(13)

SQL identifier of a cached cursor

COMMAND_TYPE

NUMBER

Code for the type of SQL statement (SELECT, INSERT, and so on)

PIECE

NUMBER

Number used to order the pieces of SQL text

SQL_TEXT

VARCHAR2(64)

A column containing one piece of the SQL text

根據piece和sql_text的長度推測,視圖v$sqltext中記錄的是一個sql切片后的信息。該視圖僅僅記錄sql的基本信息(sql的地址及內容),沒有記錄統計信息等。

V$SQLAREA和V$SQL

這2個視圖比較相似,所以對比分析。

V$SQLAREAlists statistics on shared SQL area and contains one row per SQL string. It provides statistics on SQL statements that are in memory, parsed, and ready for execution.

V$SQLlists statistics on shared SQL area without theGROUP BYclause and contains one row for each child of the original SQL text entered. Statistics displayed inV$SQLare normally updated at the end of query execution. However, for long running queries, they are updated every 5 seconds. This makes it easy to see the impact of long running SQL statements while they are still in progress.

從文檔的定義中去看,v$sql應該是V$SQLAREA沒有group by的結果,反過來說,V$SQLAREA是v$sql group by后的結果。具體是根據什麽來group by的呢?等下看能不能從視圖的定義中得到答案。

 

 

以下為整理出來的2個視圖中有差異的欄位。根據紅色部份所示,V$SQLAREA應該是parent cursor的信息,v$sql應該是child curosr的信息。

 

 

Column

Datatype

Description

1組

V$SQLAREA

VERSION_COUNT

NUMBER

Number of child cursors that are present in the cache under this parent

V$SQL

 

 

 

 

 

2組

V$SQLAREA

V$SQL

TYPE_CHK_HEAP

RAW(4)

Descriptor of the type check heap for this child cursor

 

 

 

 

 

3組

V$SQLAREA

V$SQL

CHILD_NUMBER

NUMBER

Number of this child cursor

 

 

 

 

 

4組

V$SQLAREA

V$SQL

SERVICE

VARCHAR2(64)

Service name

 

 

 

 

 

5組

V$SQLAREA

V$SQL

SERVICE_HASH

NUMBER

Hash value for the name listed in SERVICE

 

 

 

 

 

6組

V$SQLAREA

V$SQL

CHILD_ADDRESS

RAW(4 | 8)

Address of the child cursor

 

 

 

 

 

7組

V$SQLAREA

LAST_ACTIVE_CHILD_ADDRESS

RAW(4)

Address (identifier) of the child cursor that was the last to be active in the group
(that is, the child cursor on behalf of which statistics in V$SQL were updated)

V$SQL

 

 

 

 

 

8組

V$SQLAREA

V$SQL

SQLTYPE

NUMBER

Denotes the version of the SQL language used for this statement

 

 

 

第二:根據v$fixed_view_definition查定義

先不看具體的欄位,先看看數據的來源

V$SQLAREA 

select   欄位 from GV$SQLAREA where inst_id = USERENV('Instance')

V$SQL 

select  欄位 from GV$SQL where inst_id = USERENV('Instance')

再根據v$fixed_view_definition朝下看:

GV$SQLAREA

select 欄位  from  x$kglcursor_child_sqlid  where kglobt02 != 0

GV$SQL

Select 欄位  from x$kglcursor_child

兩個內部表該怎麼去理解呢?目前還不清楚,暫停留在這裡。

附上原始帖子:http://www.itpub.net/thread-181450-1-1.html

 

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

转载于:http://blog.itpub.net/25609824/viewspace-1148137/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值