From: | Michael Glaesemann <grzm(at)myrealbox(dot)com> |
---|---|
To: | siracusa(at)mindspring(dot)com |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Date column that defaults to 'now' |
Date: | 2004-01-05 21:29:45 |
Message-ID: | 47FD71B4-3FC6-11D8-BA4F-000A95C88220@myrealbox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi John!
On Jan 5, 2004, at 3:00 PM, John Siracusa wrote:
> How can I create a non-null date column that defaults to 'now' as
> computed
> at the time the row is inserted?
How about this?
test=# create table johns (comment text not null,this_time timestamp
not null default now(), this_date date not null default now());
CREATE TABLE
test=# insert into johns (comment) values ('Ars Technica rocks!');
INSERT 1196312 1
test=# select * from johns;
comment | this_time | this_date
---------------------+----------------------------+------------
Ars Technica rocks! | 2004-01-05 15:25:52.501707 | 2004-01-05
(1 row)
(If you're not the John Siracusa who writes for Ars Technica, the
sentiment still holds. :) )
Regards,
Michael Glaesemann
grzm myrealbox com
From | Date | Subject | |
---|---|---|---|
Next Message | John Siracusa | 2004-01-05 22:16:55 | Re: Date column that defaults to 'now' |
Previous Message | Oliver Elphick | 2004-01-05 21:18:15 | Re: Date column that defaults to 'now' |