Lists: | pgsql-general |
---|
From: | Prabu Subroto <prabu_subroto(at)yahoo(dot)com> |
---|---|
To: | Postgres General Milis <pgsql-general(at)postgresql(dot)org> |
Subject: | altering the datatype of a column. |
Date: | 2004-08-04 17:47:26 |
Message-ID: | 20040804174726.84664.qmail@web41804.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Dear my friends...
I want to change the datatype of a completed table
(has had already content).
But I don't know how.
Here is my try:
"
kv=# alter table customer alter column address set
type char(150);
ERROR: syntax error at or near "type" at character 47
kv=# alter table customer alter column address set
datatype char(150);
ERROR: syntax error at or near "datatype" at
character 47
kv=#
"
Please tell me how.
If I alter the datatype of the field, am I going to
loose the data inside the column?
Thank you very much in advance.
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
From: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | Prabu Subroto <prabu_subroto(at)yahoo(dot)com> |
Cc: | Postgres General Milis <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: altering the datatype of a column. |
Date: | 2004-08-04 18:02:24 |
Message-ID: | 1091642544.31602.3090.camel@linda |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Wed, 2004-08-04 at 18:47, Prabu Subroto wrote:
> Dear my friends...
>
> I want to change the datatype of a completed table
> (has had already content).
> But I don't know how.
...
> Please tell me how.
It is not possible in 7.4
Create a new column of the correct type; update the table to set the new
column to have the data from the old one; delete the old column; rename
the new one.
--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"And not only so, but we glory in tribulations also;
knowing that tribulation worketh patience; And
patience, experience; and experience, hope."
Romans 5:3,4