Re: How can I change type of column

From: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
To: mlists <mlists(at)panforma(dot)co(dot)yu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I change type of column
Date: 2004-03-31 16:59:38
Message-ID: 20040331105938.G1749@mofo.meme.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 2004.03.31 09:36 mlists wrote:
> Can I change type of column with alter table command?
>
> For instance if I have a table t1 and column c1 which is defined as
> decimal(18, 2) and I want to change it into decimal(18, 3) in MS SQL
> server I can write:
>
> alter table t1 alter column c1 decimal(18, 3)
>
> Is there something similar in PostgreSQL? Tnx in advance.

Not that I know of. You either have to add a new column,
copy the data with UPDATE, drop the old column, and then alter the new
column to disallow NULL if necessary or you have to
do a pg_dump on the table and drop and re-create the table.
The latter if you've scripts or whatever relying on the
'order' of the columns as returned with SELECT * type
statements.

Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Diogo Biazus 2004-03-31 17:03:45 Re: Wich hardware suits best for large full-text indexed
Previous Message Tom Lane 2004-03-31 16:53:25 Re: Documentation clairification?, CHECK constraints