pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Change column data type
4+ messages / 4 participants
[nested] [flat]

* Change column data type
@ 2003-09-02 09:50 Senthil Kumar S <ssakkaravel@ivesia.com>
  2003-09-05 08:15 ` Re: Change column data type Richard Huxton <dev@archonet.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Senthil Kumar S @ 2003-09-02 09:50 UTC (permalink / raw)
  To: pgsql-sql

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.

Thanks for ur knowledge sharing.


Regards
Kumar

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Change column data type
  2003-09-02 09:50 Change column data type Senthil Kumar S <ssakkaravel@ivesia.com>
@ 2003-09-05 08:15 ` Richard Huxton <dev@archonet.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Richard Huxton @ 2003-09-05 08:15 UTC (permalink / raw)
  To: Senthil Kumar S <ssakkaravel@ivesia.com>; pgsql-sql

On Tuesday 02 September 2003 10:50, Senthil Kumar S 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.
>
> Thanks for ur knowledge sharing.

If you mean changing a varchar to a date or int4 to text, then no. If you want 
to change the size of a varchar field, people seem to have done that in the 
past (check the archives for details).

Otherwise, you'll have to wrap the drop/recreate in a transaction along with 
whatever supporting updates you need.
-- 
  Richard Huxton
  Archonet Ltd



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Fw: Change column data type
@ 2003-09-02 10:57 Kumar <sgnerd@yahoo.com.sg>
  2003-09-04 15:16 ` Re: Fw: Change column data type scott.marlowe <scott.marlowe@ihs.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Kumar @ 2003-09-02 10:57 UTC (permalink / raw)
  To: pgsql-sql


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.

Thanks for ur knowledge sharing.


Regards
Kumar

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Fw: Change column data type
  2003-09-02 10:57 Fw: Change column data type Kumar <sgnerd@yahoo.com.sg>
@ 2003-09-04 15:16 ` scott.marlowe <scott.marlowe@ihs.com>
  0 siblings, 0 replies; 4+ messages in thread

From: scott.marlowe @ 2003-09-04 15:16 UTC (permalink / raw)
  To: Kumar <sgnerd@yahoo.com.sg>; +Cc: pgsql-sql

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;




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-09-05 08:15 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-02 09:50 Change column data type Senthil Kumar S <ssakkaravel@ivesia.com>
2003-09-05 08:15 ` Richard Huxton <dev@archonet.com>
2003-09-02 10:57 Fw: Change column data type Kumar <sgnerd@yahoo.com.sg>
2003-09-04 15:16 ` scott.marlowe <scott.marlowe@ihs.com>

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