Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e55FSdO27263 for ; Mon, 5 Jun 2000 11:28:39 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id LAA12068; Mon, 5 Jun 2000 11:27:49 -0400 (EDT) To: rslifka@home.com cc: pgsql-sql@postgresql.org Subject: Re: Default timestamp value In-reply-to: <001101bfcec0$8683f1e0$39117118@cr699264-a.rct1.bc.wave.home.com> References: <001101bfcec0$8683f1e0$39117118@cr699264-a.rct1.bc.wave.home.com> Comments: In-reply-to "Rob S." message dated "Mon, 05 Jun 2000 00:34:47 -0700" Date: Mon, 05 Jun 2000 11:27:49 -0400 Message-ID: <12065.960218869@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200006/38 "Rob S." writes: > ...but I still don't see how to have the default value of a timestamp to be > the time at which the individual record is inserted. I just get the time I > created the table. Specifically, what to put where the '?' is at. > ... "TimeDate" TIMESTAMP DEFAULT ? ... In 7.0 either "'now'" or "now()" should work, eg regression=# create table foo (f1 int, f2 timestamp default now()); CREATE regression=# insert into foo values(1); INSERT 395192 1 regression=# insert into foo values(2); INSERT 395193 1 regression=# select * from foo; f1 | f2 ----+------------------------ 1 | 2000-06-05 11:15:25-04 2 | 2000-06-05 11:15:28-04 (2 rows) Versions before 7.0 are not entirely consistent about this, but I believe the explicit function call now() will work the way you want in any version. BTW, this *is* covered in the FAQ, see http://www.postgresql.org/docs/faq-english.html#4.22 regards, tom lane