ALTER TABLE ... SET DEFAULT

Поиск
Список
Период
Сортировка
От Brian McCane
Тема ALTER TABLE ... SET DEFAULT
Дата
Msg-id 20020412015602.S18686-100000@fw.mccons.net
обсуждение исходный текст
Ответ на Re: More question about plans & explain (long)  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: ALTER TABLE ... SET DEFAULT  (Brian McCane <bmccane@mccons.net>)
Re: ALTER TABLE ... SET DEFAULT  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-admin

I have a field called 'updated' of type 'integer' in a table.  I have
created a function called 'since_epoch' which is declared with iscacheable
and returns the value of 'extract(epoch from now())'.  I want to make
'updated' have a default of 'since_epoch()'.  I cannot get it to work with
the following command:

alter table foo alter column updated set default 'since_epoch()' ;

this gets the error:

ERROR:  pg_atoi: error in "since_epoch()": can't parse "since_epoch()"

I tried using 'since_epoch()::integer', but that failed as well.
Is it possible to make the default value of an integer field use a
function similar to how we use 'now()' for date and timestamp fields?

- brian

Wm. Brian McCane                    | Life is full of doors that won't open
Search http://recall.maxbaud.net/   | when you knock, equally spaced amid those
Usenet http://freenews.maxbaud.net/ | that open when you don't want them to.
Auction http://www.sellit-here.com/ | - Roger Zelazny "Blood of Amber"


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: More question about plans & explain (long)
Следующее
От: Brian McCane
Дата:
Сообщение: Re: ALTER TABLE ... SET DEFAULT