X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B9081D1B899 for ; Thu, 4 Sep 2003 15:19:54 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 47409-04 for ; Thu, 4 Sep 2003 12:19:44 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id A9533D1B89A for ; Thu, 4 Sep 2003 12:19:43 -0300 (ADT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h84FHup5003000; Thu, 4 Sep 2003 09:17:56 -0600 (MDT) Date: Thu, 4 Sep 2003 09:16:01 -0600 (MDT) From: "scott.marlowe" To: Kumar Cc: psql Subject: Re: Fw: Change column data type In-Reply-To: <002a01c37140$fe6edd70$7502a8c0@hdsc.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/16 X-Sequence-Number: 14994 On Tue, 2 Sep 2003, Kumar wrote: > > Dear Friends, > > Using Postgres 7.3.4 over the linux server 7.3. > > Is it possible to alter/change the data type of a existing table's > column, with out dropping and recreating a column of same name. Only for certain types, and only by hacking the system catalogs, which is a procedure fraught with danger. i.e. backup all your data, then proceed with caution. Generally, it's best to create a new column and put the data in there and drop the old column. Note you can do this in a transaction, so you can roll it back should you realize you've made some kind of error. begin; alter table t1 add column c1 int8; update t1 set c1=c2; alter table t1 drop column c2; commit; vacuum;