Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D4F572E003E for ; Mon, 25 Feb 2008 21:41:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 17258-07 for ; Mon, 25 Feb 2008 21:41:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from epo-int2.asu.edu (epo-int2.asu.edu [129.219.187.21]) by postgresql.org (Postfix) with ESMTP id C30FA2E0039 for ; Mon, 25 Feb 2008 21:41:46 -0400 (AST) Received: from cyrus.dhcp.asu.edu (cyrus.dhcp.asu.edu [129.219.57.91]) by epo-int2.asu.edu (Switch-3.1.8/Switch-3.1.7/asu-postoffice-prod) with ESMTP id m1Q1fddq010920 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO); Mon, 25 Feb 2008 18:41:39 -0700 From: David Bear Organization: College of Public Programs To: "Aaron Bono" Subject: Re: example of insert timestamp Date: Mon, 25 Feb 2008 18:46:37 -0700 User-Agent: KMail/1.9.5 Cc: pgsql-admin@postgresql.org References: <200802251821.19453.david.bear@asu.edu> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200802251846.38100.david.bear@asu.edu> X-Virus-Scanned: by amavisd-new X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/328 X-Sequence-Number: 28402 On Monday 25 February 2008 18:21, Aaron Bono wrote: > On Mon, Feb 25, 2008 at 7:21 PM, David Bear 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. > > 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