pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Bear <david.bear@asu.edu>
To: Aaron Bono <aaron.bono@aranya.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: example of insert timestamp
Date: Mon, 25 Feb 2008 18:46:37 -0700
Message-ID: <200802251846.38100.david.bear@asu.edu> (raw)
In-Reply-To: <bf05e51c0802251721h48fa1d12i1993459170c805fe@mail.gmail.com>
References: <200802251821.19453.david.bear@asu.edu>
	<bf05e51c0802251721h48fa1d12i1993459170c805fe@mail.gmail.com>

On Monday 25 February 2008 18:21, Aaron Bono wrote:
> On Mon, Feb 25, 2008 at 7:21 PM, David Bear <david.bear@asu.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



view thread (7+ messages)  latest in thread

Message-ID: <200802251846.38100.david.bear@asu.edu>
Permalink:  ../200802251846.38100.david.bear@asu.edu/
Also on:    postgresql.org/message-id/200802251846.38100.david.bear@asu.edu

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: david.bear@asu.edu, aaron.bono@aranya.com
  Subject: Re: example of insert timestamp
  In-Reply-To: <200802251846.38100.david.bear@asu.edu>

* 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