On 03/16/2014 06:54 PM, Bob M wrote:
On a regular basis I add a new record and delete the oldest record in my
table
The records have a key and up until recently were listed by date/time order
as I wish to have them

I understand that this is unnecessary but it is great to always find the
latest records at the end of the table

Now, after a tweek in the code, my newest records are being written at the
beginning of the table next to the oldest records ?????

What code do I need to add, so that when any new record is added, it will
appear at the end of the table and not at the beginning ?

At the risk of sounding somewhat pedantic: A database table is NOT an array on disk. You do NOT control where (physically) your records end up. The order in which you SEE records is determined by the ORDER BY clause you use for your query.

If you don't specify an ORDER BY clause it may appear that the order is predictable and that it corresponds to the chronological order in which records were inserted, but this is merely a coincidence, and cannot be relied upon.

Derby does not, unlike some other databases, automatically add a rowid column to your table that is always increased when adding records to the table. You can create such a column manually - see

https://builds.apache.org/job/Derby-docs/lastSuccessfulBuild/artifact/trunk/out/ref/index.html

--
Regards,

Dyre

Reply via email to