Re: Date column that defaults to 'now'

Поиск
Список
Период
Сортировка
Искать
От
Michael Glaesemann
Тема
Re: Date column that defaults to 'now'
Дата
Msg-id
47FD71B4-3FC6-11D8-BA4F-000A95C88220@myrealbox.com
Ответ на
Список
Дерево обсуждения
Date column that defaults to 'now' John Siracusa <siracusa@mindspring.com>
Re: Date column that defaults to 'now' Oliver Elphick <olly@lfix.co.uk>
Re: Date column that defaults to 'now' Michael Glaesemann <grzm@myrealbox.com>
Re: Date column that defaults to 'now' John Siracusa <siracusa@mindspring.com>
Re: Date column that defaults to 'now' Gaetano Mendola <mendola@bigfoot.com>
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

В списке pgsql-general по дате отправления
От: Oliver Elphick
Дата:
От: John Siracusa
Дата:
FAQ