是否可以知道 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/