Oracle SQL/Java:从查询中获取返回的数据集的大小 [英] Oracle SQL / Java : Get the size of returned dataset from a query
问题描述
是否有可能知道SQL语句返回的数据集的大小(以字节为单位)
Is it possible to know the size of a dataset returned by a SQL statement in bytes
如果从查询本身中我可以得到数据的大小,那将是很好的.我找到了类似使用SQL Plus的内容,但是无法在Java代码中使用它.
It would be nice if from the query itself I can get the size of the data. I found something like using SQL Plus, but I could not use that in my Java codes.
我知道也许有一些方法可以使用Java,有人可以指导我如何做到这一点.
I know there maybe ways in doing it Java, can anyone guide me on how can I do that.
谢谢.
推荐答案
文档:
ResultSet
对象维护一个游标,该游标指向其当前数据行.最初,光标位于第一行之前. next方法将光标移动到下一行,并且由于ResultSet对象中没有更多行时它返回false,因此可以在while循环中使用它来迭代结果集.
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
不是集合,它只是用于以行方式获取数据的游标的抽象.
ResultSet
is not a collection, it is merely an abstraction of the cursor that is being used to get the data in a row-wise manner.
那么,到底需要什么呢?存储结果所需的内存量?数据库中数据的大小? ...? 为什么会很好?
So, what exactly do need? The amount of memory needed to store the result? The size of the data in the database? ...? Why would it be nice?
您始终可以执行SELECT COUNT(*) FROM
并使用特定的行平均大小来估计结果大小...代替使用SELECT COUNT(*)
,您可以使用更复杂的方法:转到最后一个元素ResultSet.last()
并获取行号:ResultSet.getRow()
.
You can always do SELECT COUNT(*) FROM
and using a certain average size of row estimate the result size... Instead of using the SELECT COUNT(*)
you can use a more convoluted way: go to the last element ResultSet.last()
and get the row number: ResultSet.getRow()
.
这篇关于Oracle SQL/Java:从查询中获取返回的数据集的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!