Re: [SQL] finding the most recent records

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: JT Kirkpatrick <jt-kirkpatrick(at)mpsllc(dot)com>
Cc: "'pgsql-sql(at)hub(dot)org'" <pgsql-sql(at)hub(dot)org>
Subject: Re: [SQL] finding the most recent records
Date: 1999-04-30 16:10:08
Message-ID: 28978.925488608@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

JT Kirkpatrick <jt-kirkpatrick(at)mpsllc(dot)com> writes:
> "field1 datetime not null default text 'now'". you'll only run into a
> problem if more than one record is inserted AT THE EXACT SAME SECOND
> -- but postgres will just put the same timestamp in there (don't
> define the field as unique).

Actually, I think "now" means "the time at the start of the current
transaction", so that you'll get the same timestamp applied to all
records inserted within a transaction. This is good for some things;
for example, you can insert related records into several different
tables and expect them to have the same timestamp, even though the
operation may take more than a second to complete. But it does mean
that you can't expect a timestamp to serve as a unique ID. (Use a
SERIAL column for that, instead...)

regards, tom lane

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Bitmead 1999-04-30 16:15:36 Re: [SQL] combining a single field in two tables into one column.
Previous Message JT Kirkpatrick 1999-04-30 16:09:08 RE: [SQL] combining a single field in two tables into one column.