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

2016-11-11 Thread Merlin Moncure
On Friday, November 11, 2016, Andreas Brandl wrote: > 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

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

2016-11-11 Thread Tom Lane
Andreas Brandl 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. Tho

[GENERAL] Change column type from int to bigint - quickest way

2016-11-11 Thread Andreas Brandl
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_attribu

Re: [GENERAL] row => text => row

2016-11-11 Thread Adrian Klaver
On 11/11/2016 12:55 AM, Marc Mamin wrote: Hello, It is possible to cast a row to text, but is there a way to revert that? e.g.: create temp table test like pg_class; WHITH dummy as (SELECT (c.*)::text t from pg_class c limit 10) INSERT INTO test SELECT ??? FROM dummy; an other option that w

Re: [GENERAL] row => text => row

2016-11-11 Thread Tom Lane
Marc Mamin writes: > It is possible to cast a row to text, but is there a way to revert that? Well, you can surely cast it back to the rowtype, but I think that answer doesn't really help you. What you seem to need is not casting to a rowtype, but "bursting" the rowtype variable into individual

[GENERAL] row => text => row

2016-11-11 Thread Marc Mamin
Hello, It is possible to cast a row to text, but is there a way to revert that? e.g.: create temp table test like pg_class; WHITH dummy as (SELECT (c.*)::text t from pg_class c limit 10) INSERT INTO test SELECT ??? FROM dummy; an other option that would sometimes help me would be to cast rows