游标(cursor )是什么?

来源:互联网 发布:rt809f编程器使用视频 编辑:程序博客网 时间:2024/06/06 15:36

Private SQL Area

 A private SQL area holds information about a parsed SQLstatement and other session-specific information for processing. When a serverprocess executes SQL or PL/SQL code, the process uses the private SQL area tostorebind variablevalues, query execution state information, and query execution work areas.

A cursor is a name or handle to a specific private SQL area. As shown inFigure 14-5,you can think of a cursor as a pointer on the client side and as a state on theserver side. Because cursors are closely associatedwith private SQL areas, the terms are sometimes usedinterchangeably

Figure 14-5 Cursor



====================================================================================================================================

永久内存区域:这里存放了相同SQL语句多次执行时都需要的一些游标信息,比如绑定变量信息、

The persistent area—This areacontains bindvariable values1

 

Cursor state

 

=++=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

CURSOR(私有SQL 区)就是一个句柄,即指针或引用,指向sql私有区(一个用户的能打开的cursor数由参数open_cursors决定)【确切说,指向sql私有区里的固定部分(The persistentarea)的开始地址,该地址也是sql私有区的开头地址】。然后sql私有区有指针指向共享sql区。私有sql区有两个部分

固定部分:绑定信息,数据结构信息,指针。随session的创建而创建,结束而释放(pmon)

动态部分:执行sql的中间结果集,如多表联查,排序。随sql的创建而创建,结束而释放。

Cursors

A cursor is a handle or name for a private SQL area—an area in memory in which a parsedstatement and other information for processing the statement are kept.

Although most Oracle users rely on the automatic cursorhandling of the Oracle utilities, the programmatic interfaces offer applicationdesigners more control over cursors. In application development, a cursor is anamed resource available to a program and can be used specifically to parse SQLstatements embedded within the application.

Each user session can open multiplecursors up to the limit set by the initialization parameterOPEN_CURSORS.However, applications should close unneeded cursors to conserve system memory.If a cursor cannot be opened due to a limit on the number of cursors, then thedatabase administrator can alter theOPEN_CURSORS initializationparameter.

Some statements (primarily DDL statements)require Oracle to implicitly issue recursive SQL statements, which also requirerecursive cursors. For example, aCREATETABLEstatement causes many updates to various data dictionary tables to record thenew table and columns. Recursive calls are made forthose recursive cursors; one cursor can run several recursive calls. Theserecursive cursors also use shared SQL areas.

参考:http://docs.oracle.com/cd/B19306_01/server.102/b14220/sqlplsql.htm#i7579

24 SQL, PL/SQL, and Java

====================================================================================================================================


疑问:

oracle服务端的shared pool上的父游标和子游标也是这个意义吗?


0 0
原创粉丝点击