Oracle SQL/Java:从查询中获取返回的数据集的大小 [英] Oracle SQL / Java : Get the size of returned dataset from a query

查看:194
本文介绍了Oracle SQL/Java:从查询中获取返回的数据集的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能知道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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆