create table foo( ... ..., _date date default current_date, ... ... ); - Mailing list pgsql-general

From louis gonzales
Subject create table foo( ... ..., _date date default current_date, ... ... );
Date
Msg-id [email protected]
Whole thread Raw
List 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:    [email protected]
WebSite:  http://www.linuxlouis.net
"Open the pod bay doors HAL!" -2001: A Space Odyssey
"Good morning starshine, the Earth says hello." -Willy Wonka


pgsql-general by date:

Previous
From: "Peter Bauer"
Date:
Subject: Major Performance decrease after some hours
Next
From: "Peter Bauer"
Date:
Subject: Re: Major Performance decrease after some hours