Re: example of insert timestamp

From: David Bear <david(dot)bear(at)asu(dot)edu>
To: "Aaron Bono" <aaron(dot)bono(at)aranya(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: example of insert timestamp
Date: 2008-02-26 01:46:37
Message-ID: 200802251846.38100.david.bear@asu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Monday 25 February 2008 18:21, Aaron Bono wrote:
> On Mon, Feb 25, 2008 at 7:21 PM, David Bear <david(dot)bear(at)asu(dot)edu> wrote:
> > I've been reading about triggers on insert and found the page at
> > http://www.postgresql.org/docs/8.1/interactive/triggers.html with some
> > sample
> > code in the comments.
> >
> > I'm thinking what I want can't really be this involved.
> >
> > I want to have a table with a timestamp field that automatically gets the
> > value of now() on insert. The timestamp will never be updated. I assume I
> > need to create a trigger to do this. If there is an easier way, please
> > advise.
> >
> > Otherwise, is there any sample code that would should be how to do this?
> > The
> > sample on the page above looks like
> > overkill.<http://www.postgresql.org/docs/faq>
>
> In your create table statement:
>
> "create_dt" TIMESTAMP WITHOUT TIME ZONE DEFAULT now() NOT NULL

Thanks. I knew it must be easier. This is exactly what I want.

--

David Bear
College of Public Programs/ASU
411 N Central, Phoenix, AZ 85004

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jamie A Lawrence 2008-02-26 02:05:09 Re: example of insert timestamp
Previous Message Steve Holdoway 2008-02-26 01:26:29 Re: example of insert timestamp