Re: I was spoiled by the MySQL timestamp field

From: "Matthew Nuzum" <cobalt(at)bearfruit(dot)org>
To: "'Lincoln Yeoh'" <lyeoh(at)pop(dot)jaring(dot)my>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: I was spoiled by the MySQL timestamp field
Date: 2003-01-26 20:04:12
Message-ID: 009001c2c576$1ad848b0$6700a8c0@mattspc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The difference is when now() gets interpreted into a date. Someone
please correct me if I'm wrong...

If you create a table at 15:00 Jan 26, 2003 and you use an unquoted
now() as the default value for a field, then each record will have it's
default value as 15:00 Jan 26, 2003.

If you quote the now(), then the default value for each newly created
record will be now() which is interpreted at the moment the record is
created.

I've used different rdbms so please forgive me if I'm documenting the
characteristics of a different system.

--
Matthew Nuzum
www.bearfruit.org
cobalt(at)bearfruit(dot)org

> -----Original Message-----
> From: Lincoln Yeoh [mailto:lyeoh(at)pop(dot)jaring(dot)my]
> Sent: Friday, January 24, 2003 4:47 AM
> To: Matthew Nuzum; 'Björn Metzdorf'; 'Alan T. Miller'; pgsql-
> general(at)postgresql(dot)org
> Subject: Re: [GENERAL] I was spoiled by the MySQL timestamp field
>
> At 03:02 PM 1/23/03 -0500, Matthew Nuzum wrote:
>
> >One word of caution, I *think* you want quotes around the 'now()'
> >statement in your table definition. Otherwise your default value will
be
> >the instant the *table* was created, not the instant your insert
> >happened.
>
> Would plain: default 'now' work? If it does (it seems to), what is the
> difference?
>
> Link.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2003-01-26 20:14:42 Re: Logging of queryies
Previous Message Iker Arizmendi 2003-01-26 19:58:05 Re: [RFC] libpq extensions - followup