Comment 1966 added to page ddl-alter.html of version 7.4

From: nobody <nobody(at)developer(dot)pgadmin(dot)org>
To: pgsql-www(at)postgresql(dot)org
Subject: Comment 1966 added to page ddl-alter.html of version 7.4
Date: 2005-01-05 17:38:35
Message-ID: 200501051738.j05HcZ5f032032@developer.pgadmin.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-www

Author: Alex French <alexfrench(at)gmail(dot)com>
----
Note that pg does not support changing the type of a column. Instead, use something like the code below to change, say, a varchar(32) into varchar(64) (assuming the collumn is called abc):

BEGIN;
ALTER TABLE mytable ADD COLUMN abc_new varchar(64);
UPDATE mytable SET abc_new = abc;
ALTER TABLE mytable RENAME abc TO abc_old;
ALTER TABLE mytable RENAME abc_new TO abc;
COMMIT;

If you're chaning the type of the column radically, you need to do more fancy type casting, but that's the theory.
----
Manual page: http://wwwmaster.postgresql.org/docs/7.4/interactive/ddl-alter.html
Reject: http://wwwmaster.postgresql.org/admin/comments.php?action=reject&id=1966
Edit: http://wwwmaster.postgresql.org/admin/comment-edit.php?id=1966
Delete: http://wwwmaster.postgresql.org/admin/comments.php?action=delete&id=1966

Responses

Browse pgsql-www by date

  From Date Subject
Next Message Robert Bernier 2005-01-05 18:06:25 Re: Link to external SRA Case Study
Previous Message Bruce Momjian 2005-01-05 17:30:17 Re: Link to external SRA Case Study