Re: viewing the original order of entered records

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Sven Van Acker <Sven(dot)Van(dot)Acker(at)vub(dot)ac(dot)be>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: viewing the original order of entered records
Date: 2003-06-13 20:40:07
Message-ID: Pine.LNX.4.33.0306131439010.21088-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 10 Jun 2003, Sven Van Acker wrote:

> Hi
>
>
>
> I've the following problem:
>
>
>
> I have a 2-column table with columns "person_id"(int4) and "phase"(text).
>
>
>
> When I entered the following records in a chronological fashion: <1, "high
> school">; <1, "childhood"> and <2, "university">;
>
>
>
>
>
> I requested the following select-statement.
>
>
>
> SELECT person_id, phase FROM life ORDER BY person_id
>
>
>
> And found the tuple <1, "childhood"> before the tuple <1, "high school">.
>
>
>
> I want to view the chronological order of my entries, but ordered by
> person_id.
>
> Is this possible in postgresql?

Yes, just make sure and store a date/time stamp when you insert the
records. You can use a before trigger to update a time stamp field on
every update of the row.

Note that without a field to "order by" neither postgresql nor any other
database guarantees any particular return order.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Maksim Likharev 2003-06-13 20:44:19 Re: return records in DB load order??
Previous Message Tom Lane 2003-06-13 20:38:07 Re: Query planner question