db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dudgeon <tdudg...@informaticsmatters.com>
Subject Re: Top 1 - Limit 1
Date Sat, 16 Sep 2006 10:04:47 GMT


Bernt M. Johnsen wrote:
> Tim Dudgeon wrote:
>>
>> Yes, but is there an equivalent to the TOP or LIMIT keywords that other
>> databases use?
> 
> Not in SQL (neither in Derby nor the SQL standard).
> The closest equivalent is Statement.setMaxRows(i).
> 

So that would not be applied at the query level?

Statement stmt = con.createStatement();
stmt.setMaxRows(1);
stmt.execute("SELECT * FROM a_very_large_table");

would run very inefficiently?
And how about

SELECT * FROM a_very_large_table ORDER BY some_column ?


using a SQL keyword like TOP or LIMIT presumably allows these to be 
optimised in some way, but stmt.setMaxRows(1) does not?

Tim



Mime
View raw message