pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Treat <xzilla@users.sourceforge.net>
To: pgsql-docs@postgresql.org
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: ALTER TABLE x ALTER COLUMN y TYPE z
Date: Wed, 22 Mar 2006 14:00:33 -0500
Message-ID: <200603221400.33513.xzilla@users.sourceforge.net> (raw)
In-Reply-To: <44213BD5.EE98.0025.0@wicourts.gov>
References: <44213BD5.EE98.0025.0@wicourts.gov>

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



view thread (6+ messages)  latest in thread

Message-ID: <200603221400.33513.xzilla@users.sourceforge.net>
Permalink:  ../200603221400.33513.xzilla@users.sourceforge.net/
Also on:    postgresql.org/message-id/200603221400.33513.xzilla@users.sourceforge.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: xzilla@users.sourceforge.net, Kevin.Grittner@wicourts.gov, tgl@sss.pgh.pa.us
  Subject: Re: ALTER TABLE x ALTER COLUMN y TYPE z
  In-Reply-To: <200603221400.33513.xzilla@users.sourceforge.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox