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


---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Reply via email to