FAQ
I created a table with column named orderdate and a default of Now() by the
following command:

CREATE TABLE "trans_test" (
"orderdate" timestamp without time zone DEFAULT timestamp 'now ( )' NOT
NULL,
etc...

The value inserted into this column when a record is inserted into the
table is the date and time the table was created. How do I get the value to
be the date and time the record is inserted short of modifying all my script
code and removing the default value?

This method did work in version 6.5. I am currently running 7.3.2.

Thank You,
Christopher A. Goodfellow
Director of Information Technology
Tealuxe, Inc.
Phone: 508 520 7887 ex:22
Fax: 508 528 8999
www.tealuxe.com
tea for all

Search Discussions

  • Tom Lane at Apr 21, 2004 at 7:03 pm

    "Christopher A. Goodfellow" <cgoodfellow@tealuxe.com> writes:
    I created a table with column named orderdate and a default of Now() by the
    following command:
    CREATE TABLE "trans_test" (
    "orderdate" timestamp without time zone DEFAULT timestamp 'now ( )' NOT
    NULL,
    That should just be
    ... DEFAULT now() ...
    or if you want to be SQL spec compliant
    ... DEFAULT LOCALTIMESTAMP ...

    What you have is a timestamp literal that is parsed at the instant of
    table creation. The parentheses are perhaps misleading you into
    thinking that you have written a function call, but you haven't ---
    the timestamp input converter is just ignoring them.

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedApr 21, '04 at 3:58p
activeApr 21, '04 at 7:03p
posts2
users2
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase