pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Defaulting to current date
2+ messages / 1 participants
[nested] [flat]

* Defaulting to current date
@ 1998-10-19 19:31  Bryan White <bryan@arcamax.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Bryan White @ 1998-10-19 19:31 UTC (permalink / raw)
  To: pgsql-sql

I wnat 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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Defaulting to current date
@ 1998-10-19 19:37  Bryan White <bryan@arcamax.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Bryan White @ 1998-10-19 19:37 UTC (permalink / raw)
  To: 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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1998-10-19 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-10-19 19:31 Defaulting to current date Bryan White <bryan@arcamax.com>
1998-10-19 19:37 Defaulting to current date Bryan White <bryan@arcamax.com>

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