Re: Change column type from int to bigint - quickest way

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Change column type from int to bigint - quickest way
Дата
Msg-id 28395.1478880739@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Change column type from int to bigint - quickest way  (Andreas Brandl <ml@3.141592654.de>)
Список pgsql-general
Andreas Brandl <ml@3.141592654.de> writes:
> we have a pretty big table with an integer-type primary key. I'm looking for the quickest way to change the column
typeto bigint to avoid hitting the integer limit. We're trying to avoid prolonged lock situations and full table
rewrites.

You have no choice.  Those types are different sizes so there is no way
to avoid a table rewrite.

> 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';

That WILL break your table.

            regards, tom lane


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

Предыдущее
От: Andreas Brandl
Дата:
Сообщение: Change column type from int to bigint - quickest way
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Change column type from int to bigint - quickest way