X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C1C599DD560 for ; Wed, 22 Mar 2006 15:00:40 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18246-02-3 for ; Wed, 22 Mar 2006 15:00:39 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from eastrmmtao04.cox.net (eastrmmtao04.cox.net [68.230.240.35]) by postgresql.org (Postfix) with ESMTP id 827F69DD56B for ; Wed, 22 Mar 2006 15:00:37 -0400 (AST) Received: from [192.168.0.8] (really [24.136.35.185]) by eastrmmtao04.cox.net (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20060322190030.HCFB19943.eastrmmtao04.cox.net@[192.168.0.8]>; Wed, 22 Mar 2006 14:00:30 -0500 From: Robert Treat To: pgsql-docs@postgresql.org Subject: Re: ALTER TABLE x ALTER COLUMN y TYPE z Date: Wed, 22 Mar 2006 14:00:33 -0500 User-Agent: KMail/1.8.3 Cc: "Kevin Grittner" , Tom Lane References: <44213BD5.EE98.0025.0@wicourts.gov> In-Reply-To: <44213BD5.EE98.0025.0@wicourts.gov> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200603221400.33513.xzilla@users.sourceforge.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200603/29 X-Sequence-Number: 3486 On Wednesday 22 March 2006 12:58, Kevin Grittner wrote: > On this page: > > http://www.postgresql.org/docs/8.1/interactive/sql-altertable.html > > there is this user comment: > > -------------------- > > To change the data type of a column, do this: > > BEGIN; > ALTER TABLE tab ADD COLUMN new_col new_data_type; > UPDATE tab SET new_col = CAST(old_col AS new_data_type); > ALTER TABLE tab RENAME old_col TO temp_name; > ALTER TABLE tab RENAME new_col TO old_col; > ALTER TABLE tab DROP COLUMN temp_name; > COMMIT; > > You might then want to do VACUUM FULL tab to reclaim the disk space > used by the expired rows. > > -------------------- > > The 8.1 release (and the 8.0 release) support the same functionality > with a single line: > > ALTER TABLE tab ALTER COLUMN old_col TYPE new_data_type; > > I think the user comment should be removed, unless there is some > benefit to using the multi-step process. If there is some benefit, I > think it should be described, so that users know when to use it instead > of the simpler technique. > I believe Tom's comments in this email apply similarly here. http://archives.postgresql.org/pgsql-general/2006-03/msg00891.php Feel free to submit an additional doc comment. -- Robert Treat Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL