| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Andreas Brandl <ml(at)3(dot)141592654(dot)de> |
| Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Change column type from int to bigint - quickest way |
| Date: | 2016-11-11 16:12:19 |
| Message-ID: | 28395.1478880739@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Andreas Brandl <ml(at)3(dot)141592654(dot)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 type to 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Merlin Moncure | 2016-11-12 01:17:59 | Re: Change column type from int to bigint - quickest way |
| Previous Message | Andreas Brandl | 2016-11-11 15:34:08 | Change column type from int to bigint - quickest way |