| От | Tom Lane |
|---|---|
| Тема | Re: Defaulting a column to 'now' |
| Дата | |
| Msg-id | 22427.1134584120@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Defaulting a column to 'now' ("Ken Winter" <ken@sunward.org>) |
| Ответы |
Re: Defaulting a column to 'now'
|
| Список | pgsql-sql |
"Ken Winter" <ken@sunward.org> writes:
> How can a column's default be set to 'now', meaning 'now' as of when each
> row is inserted?
You need a function, not a literal constant. The SQL-spec way isCURRENT_TIMESTAMP
(which is a function, despite the spec's weird idea that it should be
spelled without parentheses); the traditional Postgres way isnow()
Either way only sets an insertion default, though. If you want to
enforce a correct value on insertion, or change the value when the
row is UPDATEd, you need to use a trigger.
regards, tom lane
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера