From: | "Bryan White" <bryan(at)arcamax(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Defaulting to current date |
Date: | 1998-10-19 19:37:46 |
Message-ID: | 00b801bdfb97$f2e3f0e0$a3f0f6ce@bryan.arcamax.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Olivier | 1998-10-20 01:18:12 | timespan question: using value from row in select |
Previous Message | Bryan White | 1998-10-19 19:31:29 | Defaulting to current date |