Subject Re: [firebird-support] Is there a way to tell the order that rows were inserted?
Author Helen Borrie
At 10:10 AM 17/08/2004 -0400, you wrote:
>Stupid question, I know, but I've gotta ask:
>I've got a table with a couple hundred thousand rows in it. There was no
>need for a primary key on the table when it was created a few years ago, nor
>is there a timestamp column.
>I have a need to know the order in which the rows were inserted. Will
>rdb$db_key allow me to ascertain the order?

No. Relational databases, by design, don't have any concept of
"order": if you need it, you have to design it in.

rdb$db_key only provides the current physical position of a row relative to
the beginning of a page of data that belongs to that table. "Rows" are just
lumps of compressed data stored *somewhere* on a page that belongs to that
table definition. New versions of rows, created by updates, can't even be
counted on to go the same position where the old version was, or even the
same page, or, where you have a multi-file database, even in the same
physical file. Deleted rows leave spaces that are eventually re-used for
new rows or row versions. Every restore tidies up the pages for a table by
filling them up to 80% capacity but, again, there is no order to it.