java - Oracle SQL/Java : Get the size of returned dataset from a query

标签 java sql oracle

是否可以知道 SQL 语句返回的数据集的大小(以字节为单位)

如果我可以从查询本身获取数据的大小,那就太好了。我发现了类似使用 SQL Plus 的东西,但我无法在我的 Java 代码中使用它。

我知道 Java 可能有一些方法,任何人都可以指导我如何做到这一点。

提前致谢。

最佳答案

Docs :

A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set.

ResultSet 不是一个集合,它只是用于以行方式获取数据的游标的抽象。

那么,到底需要什么?存储结果需要多少内存?数据库中数据的大小? ...? 为什么会很好?

您始终可以执行 SELECT COUNT(*) FROM 并使用特定的平均行大小来估计结果大小...而不是使用 SELECT COUNT(*) > 您可以使用更复杂的方法:转到最后一个元素 ResultSet.last() 并获取行号:ResultSet.getRow()

关于java - Oracle SQL/Java : Get the size of returned dataset from a query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10204996/

相关文章:

java - SHA1 哈希在 Java 中未按预期工作

sql - 从 select 语句推断的 Postgres 隐式类型

python - super 集仪表板 - 动态更新

python - 在单个域上使用两个不同的框架 (Oracle Weblogic/Django)

java - Android是设备电源连接而没有广播接收器

java - 如何在 JSON 结构中的特定对象上使用自定义 Jackson JsonDeserializer<T> 类?

python - 多对多 Django sql

php - 如何从数据库中放入 <select> 类别和子类别?

oracle - Oracle中的错误 "PLS-00363: expression cannot be used as an assignment target"如何解决?

java - ComboBox (setSelectedIndex()) 无法正常工作