Re: serial data type

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: Joseph Healy <joe_healy(at)dodo(dot)com(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: serial data type
Date: 2004-09-26 00:33:59
Message-ID: 87r7opq360.fsf@asmodeus.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joseph Healy <joe_healy(at)dodo(dot)com(dot)au> writes:

> On Sat, Sep 25, 2004 at 07:20:23PM -0400, Tom Allison wrote:
>>
>> Any idea how to set up a timestamp=now on every insert/update ?
>
> when you create your table, use:
>
> create table mytable (
> id serial primary key,
> updated timestamp default(now()),
> mydata int4
> );

That won't change the timestamp on UPDATE queries; you need a trigger
for that.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2004-09-26 01:06:45 Re: using COPY table FROM STDIN within script run as psql
Previous Message gearond 2004-09-26 00:20:54 IN or JOIN