pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Timo Roessner <timo.roessner@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: datatype conversion on postgresql 7.4.1
Date: Tue, 24 May 2005 08:45:46 +0100
Message-ID: <4292DBAA.7030408@archonet.com> (raw)
In-Reply-To: <42906D06.3090200@gmx.net>
References: <42906D06.3090200@gmx.net>

Timo Roessner wrote:
> and if i try something like:
> 
> alter table fragment alter column  x type numeric(15,2)
> 
> i get an syntax error, so this seems to be no feature in 7.4.1 (didnt 
> find anything like that in the docs too....)
> 
> what can i do to solve this? there must be some way in postgresql 7.4.1, 
> if there is no way to do that, i have to
> build up the whole database from scratch........there must be a way to 
> convert float to numeric values in 7.4.1 ,
> but i dont have a single clue...

There isn't a way to directly convert the type of a column in 7.4.x but 
you can duplicate the effect.

BEGIN;
ALTER TABLE fragment RENAME COLUMN x TO old_x;
ALTER TABLE fragment ADD COLUMN x numeric(10,2);
UPDATE fragment SET x = old_x;
ALTER TABLE fragment DROP COLUMN old_x;
COMMIT;

Make sure you check any functions/application code that might be 
expecting floating-point rather than numeric before you do this.

Oh, and upgrade from 7.4.1 to 7.4.7 as soon as possible.
--
   Richard Huxton
   Archonet Ltd



view thread (2+ messages)

Message-ID: <4292DBAA.7030408@archonet.com>
Permalink:  ../4292DBAA.7030408@archonet.com/
Also on:    postgresql.org/message-id/4292DBAA.7030408@archonet.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: dev@archonet.com, timo.roessner@gmx.net
  Subject: Re: datatype conversion on postgresql 7.4.1
  In-Reply-To: <4292DBAA.7030408@archonet.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