Defaulting to current date
От | Bryan White |
---|---|
Тема | Defaulting to current date |
Дата | |
Msg-id | 00b801bdfb97$f2e3f0e0$a3f0f6ce@bryan.arcamax.com обсуждение исходный текст |
Список | 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
В списке pgsql-sql по дате отправления: