Skip site navigation (1) Skip section navigation (2)

Re: ALTER TABLE x ALTER COLUMN y TYPE z

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: pgsql-docs(at)postgresql(dot)org, "Robert Treat" <xzilla(at)users(dot)sourceforge(dot)net>
Subject: Re: ALTER TABLE x ALTER COLUMN y TYPE z
Date: 2006-03-22 20:14:44
Message-ID: 19259.1143058484@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-docs
"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> The user comment's recommended technique includes this line:
> ALTER TABLE tab DROP COLUMN temp_name;
> Would this cause a table rewrite?  (Not a rhetorical question.  I
> really don't know.)

No, it wouldn't.  The UPDATE is the only part that modifies the table
contents.

However, the arguments Robert pointed to had to do with concurrent
access to the table, and somehow I am not seeing the use-case for ALTER
COLUMN TYPE on a table that's being actively used by other clients.
It seems unlikely that you could do that without needing to also update
your client software.  I'd be a tad worried about stale-cached-plan
problems too, in current PG releases.  Finally, since the first ALTER
will take an exclusive lock that won't be released until COMMIT, this
approach doesn't avoid the problem of holding exclusive lock for a long
time.

			regards, tom lane

In response to

Responses

pgsql-docs by date

Next:From: Robert TreatDate: 2006-03-22 21:50:20
Subject: Re: ALTER TABLE x ALTER COLUMN y TYPE z
Previous:From: Kevin GrittnerDate: 2006-03-22 20:01:13
Subject: Re: ALTER TABLE x ALTER COLUMN y TYPE z

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group