From: Tom Lane <tgl@sss.pgh.pa.us>
To: rslifka@home.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Default timestamp value
Date: Mon, 05 Jun 2000 11:27:49 -0400
Message-ID: <12065.960218869@sss.pgh.pa.us> (raw)
In-Reply-To: <001101bfcec0$8683f1e0$39117118@cr699264-a.rct1.bc.wave.home.com>
References: <001101bfcec0$8683f1e0$39117118@cr699264-a.rct1.bc.wave.home.com>
"Rob S." <rslifka@home.com> 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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, rslifka@home.com
Subject: Re: Default timestamp value
In-Reply-To: <12065.960218869@sss.pgh.pa.us>
References: <001101bfcec0$8683f1e0$39117118@cr699264-a.rct1.bc.wave.home.com> <12065.960218869@sss.pgh.pa.us>
* 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