Re: How do I make a timestamp column default to current time
В списке pgsql-general по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: How do I make a timestamp column default to current time |
| Дата | |
| Msg-id | 17573.1142527298@sss.pgh.pa.us обсуждение |
| Ответ на | How do I make a timestamp column default to current time ("zagman" <daveh@allheller.net>) |
| Ответы |
Re: How do I make a timestamp column default to current time
|
| Список | pgsql-general |
"zagman" <daveh@allheller.net> writes:
> I'm setting up a simple timecard program and I need a column that
> defaults to the current time when a new row is inserted. How can I do
> this I tried setting the default to 'now' but all that does is put the
> time I created the table in each row!
The default has to be a function call, not a literal constant, to work
the way you want. Try
mycol timestamp default now()
or
mycol timestamp default current_timestamp
(the latter is actually a function call, even though the SQL standard
says it has to be spelled without any parentheses)
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера