X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 8D69B9DC830 for ; Wed, 14 Dec 2005 14:15:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46960-01 for ; Wed, 14 Dec 2005 14:15:21 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 190419DC82E for ; Wed, 14 Dec 2005 14:15:19 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jBEIFKNc022428; Wed, 14 Dec 2005 13:15:20 -0500 (EST) To: "Ken Winter" cc: "PostgreSQL pg-sql list" Subject: Re: Defaulting a column to 'now' In-reply-to: <003501c600d9$b799a1c0$6603a8c0@kenxp> References: <003501c600d9$b799a1c0$6603a8c0@kenxp> Comments: In-reply-to "Ken Winter" message dated "Wed, 14 Dec 2005 13:10:50 -0500" Date: Wed, 14 Dec 2005 13:15:20 -0500 Message-ID: <22427.1134584120@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.002 required=5 tests=[AWL=0.002] X-Spam-Score: 0.002 X-Spam-Level: X-Archive-Number: 200512/122 X-Sequence-Number: 23664 "Ken Winter" writes: > How can a column's default be set to 'now', meaning 'now' as of when each > row is inserted? You need a function, not a literal constant. The SQL-spec way is CURRENT_TIMESTAMP (which is a function, despite the spec's weird idea that it should be spelled without parentheses); the traditional Postgres way is now() Either way only sets an insertion default, though. If you want to enforce a correct value on insertion, or change the value when the row is UPDATEd, you need to use a trigger. regards, tom lane