如何限制Sybase返回的结果数量? [英] How do I limit the amount of results returned in Sybase?

查看:121
本文介绍了如何限制Sybase返回的结果数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要查询其中包含大量数据的Sybase数据库,并希望设置一个限制,以便DB在10个结果后停止查询.

I need to query a Sybase database which has a lot of data in it, and would like to set a limit so the DB stops the query after 10 results.

关键是性能,因此如果先搜索所有结果然后返回最后10个结果,那将毫无用处.

The key thing is performance, so it would be no use if it searched all results and then then returned the last 10 results.

预先感谢

推荐答案

我相信您可以先执行SET ROWCOUNT 10,然后执行此会话中的所有查询,直到再执行SET ROWCOUNT都将返回不超过10行.正如评论所指出的那样,这会影响会话中所有查询后的 all (不仅仅是SELECT s!),直到将其关闭(设置为0)或进行其他设置-这种全局"效果使它比其他引擎的典型LIMIT子句少用了,该子句本质上是每个查询,但是,我认为您对此无能为力.

I believe you can do a SET ROWCOUNT 10 first, then all queries in this session until a further SET ROWCOUNT will return no more than 10 rows. As a comment points out, this affects all following queries in the session (not just SELECTs!) until turned off (by setting to 0) or set differently -- this "global" effect makes it less handy than the typical LIMIT clause of other engines, which is inherently per-query, but, I don't think you can do anything about that.

这篇关于如何限制Sybase返回的结果数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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