Re: Default timestamp value

From: Thomas Behr <thomas(dot)behr(at)bnv-bamberg(dot)de>
To: rslifka(at)home(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Default timestamp value
Date: 2000-06-05 08:13:22
Message-ID: 393B6122.5493B9F8@bnv-bamberg.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Rob S." wrote:
>
> As a precursor to this question, I read:
>
> CREATE TABLE
> Date/Time Types (and corresponding input/output)
> Date/Time Functions
>
> ...but I still don't see how to have the default value of a timestamp to be
> the time at which the individual record is inserted. I just get the time I
> created the table. Specifically, what to put where the '?' is at.
>
> ... "TimeDate" TIMESTAMP DEFAULT ? ...

Hallo Rob,
an example, which works by me [PostgreSQL 6.4.2 on i686-pc-linux-gnu,
compiled by gcc 2.7.2.]:

CREATE TABLE "session" (
"zeitpunkt" timestamp DEFAULT now ( ) NOT NULL,
"sid" int4 NOT NULL,
"nummer" int4 NOT NULL,
"status" character varying NOT NULL,
"host" inet);

Ade

Thomas

>
> I tried 'now' and 'current' but it just makes the default value the time
> when I create the table, and 'current' gives me the word 'current' back in
> psql, so I imagine I'm not taking that in quite the right way =) I can see
> why it does this for both of these, althought in the docs, it says current
> is current time, deferred, but I dunno what that means.
>
> Any help or pointers to a nice resource? IMHO, the PG docs are a great
> reference, but not much in the way of terrific examples =)
>
> - r

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kovacs Zoltan Sandor 2000-06-05 08:32:59 SQL functions - bug?
Previous Message Rob S. 2000-06-05 07:34:47 Default timestamp value