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

Re: example of insert timestamp

From: "Aaron Bono" <aaron(dot)bono(at)aranya(dot)com>
To: "David Bear" <david(dot)bear(at)asu(dot)edu>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: example of insert timestamp
Date: 2008-02-26 01:21:21
Message-ID: bf05e51c0802251721h48fa1d12i1993459170c805fe@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
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

-- 
==================================================================
  Aaron Bono
  Aranya Software Technologies, Inc.
  http://www.aranya.com
  http://codeelixir.com
==================================================================

In response to

Responses

pgsql-admin by date

Next:From: Steve HoldowayDate: 2008-02-26 01:26:29
Subject: Re: example of insert timestamp
Previous:From: David BearDate: 2008-02-26 01:21:19
Subject: example of insert timestamp

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