Oracle游标的查询

简介: The initialization parameter OPEN_CURSORS in INITSID.ORA determines the maximum number of cursors per user.
The initialization parameter OPEN_CURSORS in INITSID.ORA determines the maximum number of cursors per user.

Check the parameter specified by executing the following SQL:
select * from v$parameter
where name = 'open_cursors'

/


If you want more cursors to be opened at the same time, shut the database, change INITSID.ORA and restart the database.

The cursors that are counted for this are those explicit cursors that you opened and never closed or the cursors the PL/SQL keeps open. If you use a lot of stored procedures, then you will see lot of cached cursors. From release 8.1, PL/SQL will close these cached cursors on commit.

You can find the list of open cursors and the users who opened them by executing the following SQL:

select user_name, status, osuser, machine, a.sql_text
from v$session b,
v$open_cursor a
where a.sid = b.sid
/


But the above SQL will tell you about cursors opened at some point of time, but does tell you about currently open cursors. But the above SQL will helps us to track cursor leaks, which would need fixing, to avoid this error in the future.

The SQL given below will tell you how many are open truly.

select a.value, b.name
from v$mystat a, v$statname b
where a.statistic# = b.statistic#
and a.statistic#= 3

/


The closing of the cursor change based on the tool you use:

In JDBC, preparedStatement.close() does closes the cursor.
In PRO*C EXEC SQL CLOSE ; does it.
In OCI -- there is an API call to close a statement

These statements will make sure you close every explicitly opened cursor.

查询游标所在的应用程序和所在的中端(电脑):
select * from (
select terminal,program,count(*)  SQLCount from v$session
group by terminal,program)
order by SQLCount desc

目录
相关文章
|
2月前
|
SQL Oracle 关系型数据库
Oracle查询优化-查询只包含数字或字母的数据
【2月更文挑战第4天】【2月更文挑战第10篇】查询只包含数字或字母的数据
86 1
|
5月前
|
存储 Oracle 关系型数据库
Oracle 代码异常查询(五)
Oracle 代码异常查询
134 0
|
3月前
|
SQL Oracle 关系型数据库
JAVAEE框架数据库技术之12_oracle常用函数和高级查询子查询
JAVAEE框架数据库技术之12_oracle常用函数和高级查询子查询
66 0
JAVAEE框架数据库技术之12_oracle常用函数和高级查询子查询
|
3天前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL游标属性:数据的“导航仪”与“仪表盘”
【4月更文挑战第19天】Oracle PL/SQL游标属性如同车辆的导航仪和仪表盘,提供丰富信息和控制。 `%FOUND`和`%NOTFOUND`指示数据读取状态,`%ROWCOUNT`记录处理行数,`%ISOPEN`显示游标状态。还有`%BULK_ROWCOUNT`和`%BULK_EXCEPTIONS`增强处理灵活性。通过实例展示了如何在数据处理中利用这些属性监控和控制流程,提高效率和准确性。掌握游标属性是提升数据处理能力的关键。
|
1月前
|
SQL 存储 Oracle
Oracle系列十三:游标
Oracle系列十三:游标
|
1月前
|
SQL Oracle 关系型数据库
Oracle系列之八:SQL查询
Oracle系列之八:SQL查询
|
5月前
|
SQL Oracle 关系型数据库
Oracle 代码异常查询(九)
Oracle 代码异常查询
139 0
|
5月前
|
SQL 存储 Oracle
Oracle 代码异常查询(三)
Oracle 代码异常查询
131 0
|
2月前
|
Oracle 关系型数据库
Oracle 递归查询
Oracle 递归查询
10 0
|
3月前
|
SQL Oracle 关系型数据库
oracle查询数据库参数sql语句
oracle查询数据库参数sql语句

推荐镜像

更多