pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
Cc: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
Subject: Re: [SQL] finding the most recent records
Date: Fri, 30 Apr 1999 12:10:08 -0400
Message-ID: <28978.925488608@sss.pgh.pa.us> (raw)
In-Reply-To: <01BE92F4.8E44C660.jt-kirkpatrick@mpsllc.com>

JT Kirkpatrick <jt-kirkpatrick@mpsllc.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



view thread (3+ messages)

Message-ID: <28978.925488608@sss.pgh.pa.us>
Permalink:  ../28978.925488608@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28978.925488608@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jt-kirkpatrick@mpsllc.com, pgsql-sql@hub.org
  Subject: Re: [SQL] finding the most recent records
  In-Reply-To: <28978.925488608@sss.pgh.pa.us>
  References: <01BE92F4.8E44C660.jt-kirkpatrick@mpsllc.com> <28978.925488608@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox