Re: change column data type of a big table

Поиск
Список
Период
Сортировка
От John R Pierce
Тема Re: change column data type of a big table
Дата
Msg-id 5024A4A3.9050707@hogranch.com
обсуждение исходный текст
Ответ на change column data type of a big table  ("Anibal David Acosta" <aa@devshock.com>)
Ответы Re: change column data type of a big table  (Rob Sargent <robjsargent@gmail.com>)
Список pgsql-general
On 08/09/12 10:31 PM, Anibal David Acosta wrote:
>
> I have a very big table, in fact only this table uses approx. 60%
> space of disk.
>
> The table is an standalone table (no one inherit from this and this is
> not inherit from another).
>
> I need to change a int column to bigint.
>
> But aparentely this alter recreate the table, my problem is the space,
> there are no space enough in disk.
>
> Is possible to change column datatype without recreating the table?
>
>

every tuple of this table will have to be rewritten with the new type.
you can't avoid that.   as none of the old tuples can be reclaimed
before the ALTER TABLE completes, you'll need sufficient disk space for
the old and new data.

I see no way of avoiding needing more disk space.    if you have
sufficient space on another drive, you could dump the table data-only,
then truncate it, then alter the type while its empty, then restore the
dump.




--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast


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

Предыдущее
От: "Anibal David Acosta"
Дата:
Сообщение: change column data type of a big table
Следующее
От: "Albe Laurenz"
Дата:
Сообщение: Re: Function to dump function ddl