Skip site navigation (1) Skip section navigation (2)

Re: example of insert timestamp

From: Jamie A Lawrence <postgres(at)jal(dot)org>
To: "Gregory Williamson" <Gregory(dot)Williamson(at)digitalglobe(dot)com>
Cc: "David Bear" <david(dot)bear(at)asu(dot)edu>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: example of insert timestamp
Date: 2008-02-26 02:05:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
On Feb 25, 2008, at 8:19 PM, Gregory Williamson wrote:
> Perhaps, make the column so it has a default value of now, land then  
> insert without specifying the timestamp column so it gets the  
> default value:
> create table foo (q_i_time timestamp with time zone not null default  
> now(), someval int);

This is what I do. For many tables, I also add a mod_time column with  
an ON UPDATE trigger similar to the one previously posted. Even when  
not needed for the table itself, in development, it can be very handy  
to compare dodgy inserts/updates with commit logs when bug hunting...


In response to


pgsql-admin by date

Next:From: Aaron BonoDate: 2008-02-26 02:41:42
Subject: Re: example of insert timestamp
Previous:From: David BearDate: 2008-02-26 01:46:37
Subject: Re: example of insert timestamp

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group