create table foo( ... ..., _date date default current_date, ... ... );

From: louis gonzales <gonzales(at)linuxlouis(dot)net>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: create table foo( ... ..., _date date default current_date, ... ... );
Date: 2006-10-01 08:37:40
Message-ID: 451F7E54.4010505@linuxlouis.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Group,
I want to set the default value of a date attribute _date to CURRENT_DATE.
CURRENT_DATE gives a format YYYY-MM-DD

my table is something similar to:

create table foo(
... ...,
_date date default current_date,
... ...);

Now, everytime a new entry is inserted, is it going to get the
CURRENT_DATE of the day of insertion? Or will this be the same value
all of the time?

The behavior I'd like is, if today is 2006-10-01,
all new entries today will get that as default.
Then tomorrow 2006-10-02
all entries will get 2006-10-02 as the default.

when I do a:
\d foo

sseq | integer |
_iseq | integer |
_comment | text |
_day | character varying(3) |
_time | character varying(5) |
_meridiem | character varying(2) |
_paymentamount | character varying(13) |
_date | date | default ('now'::text)::date
Foreign-key constraints:
"paymenthistory__iseq_fkey" FOREIGN KEY (_iseq) REFERENCES
instructor(_iseq)
"paymenthistory_sseq_fkey" FOREIGN KEY (sseq) REFERENCES students(sseq)

Is this going to give the desired behavior?

Thanks,

--
Email: louis(dot)gonzales(at)linuxlouis(dot)net
WebSite: http://www.linuxlouis.net
"Open the pod bay doors HAL!" -2001: A Space Odyssey
"Good morning starshine, the Earth says hello." -Willy Wonka

Browse pgsql-general by date

  From Date Subject
Next Message Peter Bauer 2006-10-01 10:21:40 Re: Major Performance decrease after some hours
Previous Message Peter Bauer 2006-10-01 06:29:09 Major Performance decrease after some hours