pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Kumar <sgnerd@yahoo.com.sg>
Cc: psql <pgsql-sql@postgresql.org>
Subject: Re: Fw: Change column data type
Date: Thu, 4 Sep 2003 09:16:01 -0600 (MDT)
Message-ID: <Pine.LNX.4.33.0309040912510.27003-100000@css120.ihs.com> (raw)
In-Reply-To: <002a01c37140$fe6edd70$7502a8c0@hdsc.com>

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;




view thread (4+ messages)  latest in thread

Message-ID: <Pine.LNX.4.33.0309040912510.27003-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0309040912510.27003-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0309040912510.27003-100000@css120.ihs.com

 · 

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-sql@postgresql.org
  Cc: scott.marlowe@ihs.com, sgnerd@yahoo.com.sg
  Subject: Re: Fw: Change column data type
  In-Reply-To: <Pine.LNX.4.33.0309040912510.27003-100000@css120.ihs.com>

* 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