Re: Default timestamp value

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Default timestamp value
Дата
Msg-id 12065.960218869@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Default timestamp value  ("Rob S." <rslifka@home.com>)
Ответы RE: Default timestamp value  ("Rob S." <rslifka@home.com>)
Список pgsql-sql
"Rob S." <rslifka@home.com> writes:
> ...but I still don't see how to have the default value of a timestamp to be
> the time at which the individual record is inserted.  I just get the time I
> created the table.  Specifically, what to put where the '?' is at.

> ... "TimeDate" TIMESTAMP DEFAULT ? ...

In 7.0 either "'now'" or "now()" should work, eg

regression=# create table foo (f1 int, f2 timestamp default now());
CREATE
regression=# insert into foo values(1);
INSERT 395192 1
regression=# insert into foo values(2);
INSERT 395193 1
regression=# select * from foo;f1 |           f2
----+------------------------ 1 | 2000-06-05 11:15:25-04 2 | 2000-06-05 11:15:28-04
(2 rows)

Versions before 7.0 are not entirely consistent about this, but I
believe the explicit function call now() will work the way you want
in any version.

BTW, this *is* covered in the FAQ, seehttp://www.postgresql.org/docs/faq-english.html#4.22
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: p.lam@altavista.net
Дата:
Сообщение: CREATE FUNCTION- Table as argument
Следующее
От: Tom Lane
Дата:
Сообщение: Re: cron job INSERT appears to bail.