Change column type from int to bigint - quickest way

Поиск
Список
Период
Сортировка
Искать
От
Andreas Brandl
Тема
Change column type from int to bigint - quickest way
Дата
Msg-id
754618294.6548.1478878448800.JavaMail.zimbra@andreas-brandl.de
Список
Дерево обсуждения
Change column type from int to bigint - quickest way Andreas Brandl <ml@3.141592654.de>
Re: Change column type from int to bigint - quickest way Tom Lane <tgl@sss.pgh.pa.us>
Re: Change column type from int to bigint - quickest way Merlin Moncure <mmoncure@gmail.com>
Hi,

we have a pretty big table with an integer-type primary key. I'm looking for the quickest way to change the column type to bigint to avoid hitting the integer limit. We're trying to avoid prolonged lock situations and full table rewrites.

I know I can hack this with an UPDATE on pg_attribute:

-- change id type to bigint
update pg_attribute set atttypid=20 where attrelid=264782 and attname = 'id';

After that I'd need to reflect the change on dependent objects like views as well.

Is this safe to do? Are there any unwanted consequences to this?

This is still on 9.1 unfortunately - upgrade is going to follow soon after this.

Thanks!
Andreas

В списке pgsql-general по дате отправления
От: Adrian Klaver
Дата:
Сообщение: Re: row => text => row
От: Tom Lane
Дата:
FAQ