From: Bryan White <bryan@arcamax.com>
To: pgsql-sql@postgresql.org
Subject: Defaulting to current date
Date: Mon, 19 Oct 1998 15:37:46 -0400
Message-ID: <00b801bdfb97$f2e3f0e0$a3f0f6ce@bryan.arcamax.com> (raw)
I want to have a field with a date/time value that defaults to the time the
record was inserted. I also want to be abled to index this field.
If I create with:
create table test
(
Date timestamp not null default CURRENT_TIMESTAMP
);
The default value works as expected but I cannot create an index:
create index testidx on test (Date);
ERROR: Can't find a default operator class for type 1296.
I have also tried to create the field as a DATETIME field.
create table test
(
Date datetime not null default CURRENT_TIME
);
I can create the index but the field defaults to the table creation time
instead of the insertion time.
I have tried several syntax variations using CURRENT_DATE, CURRENT_TIME,
CURRENT_TIMESTAMP, 'now', and text 'now'. The last one is suggested in the
online documentation, however they refer specifically to v6.4 and I am
running 6.3.2.
It seems like I can index the field or used a default value but not both.
Is this true?
Bryan White
ArcaMax Inc.
Yorktown VA
www.arcamax.com
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: bryan@arcamax.com
Subject: Re: Defaulting to current date
In-Reply-To: <00b801bdfb97$f2e3f0e0$a3f0f6ce@bryan.arcamax.com>
References: <00b801bdfb97$f2e3f0e0$a3f0f6ce@bryan.arcamax.com>
* 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