On Tue, 2024-04-16 at 09:54 +0000, 'Peter Borissow' via H2 Database
wrote:
> Hmm... I kinda have a row id already via the unique primary key. What
> advantage would a temp table give in my case?

The advantage is, that special column _rowid_ is the physical row of
the data frame and it would not change unless you shuffle the data.
It's comparable to Oracle's rownum.

Complete example:
drop table test if exists cascade;

create table test(a int, b int, constraint a_key primary key (a));
insert into test values (1, 2), (2, 3), (3, 3), (4, 4), (5, 4), (6, 4), (7, 4);

create table tmp_test
as select * from test order by b;

select * from tmp_test order by _rowid_ offset 0 rows fetch next 3 row only;


select * from tmp_test order by _rowid_ offset 3 rows fetch next 3 row only;


select * from tmp_test order by _rowid_ offset 6 rows fetch next 3 row only;

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/6b8f9eefa7632155c94b059db9fc1a170ff61473.camel%40manticore-projects.com.

Reply via email to