alter column type

From: Casey Deccio <casey(at)deccio(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: alter column type
Date: 2015-06-05 16:23:16
Message-ID: CAEKtLiTpsdi=_zKeBE-sqwaY=cNG0Obnn2AWWqB7aX_YJfV+_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a database in which one table references the primary key of
another. The type of the primary key was initially int, but I changed it
to bigint. However, I forgot to update the type of a column that
references it. So, I've initiated "ALTER TABLE foo ALTER COLUMN bar TYPE
bigint", where foo/bar is the table/column referencing the primary key that
is now of type bigint.

However, with 2^31 rows, it is taking a "long" time to write the rows (it's
been 12 hours). Is there a more efficient way to do this? Even if/when
this one finishes, there are other column types that I have to update.
This update effectively locked me out of all access to the data anyway, so
I don't foresee any concern of writes that might affect integrity.

Cheers,
Casey

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sheena, Prabhjot 2015-06-05 17:54:39 Query running slow for only one specific id. (Postgres 9.3) version
Previous Message Andres Freund 2015-06-05 16:00:14 Re: [GENERAL] 9.4.1 -> 9.4.2 problem: could not access status of transaction 1