create table foo( ... ..., _date date default current_date, ... ... );
От | louis gonzales |
---|---|
Тема | create table foo( ... ..., _date date default current_date, ... ... ); |
Дата | |
Msg-id | 451F7E54.4010505@linuxlouis.net обсуждение исходный текст |
Список | 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.gonzales@linuxlouis.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
В списке pgsql-general по дате отправления: