Thread: altering the datatype of a column.

altering the datatype of a column.

From
Prabu Subroto
Date:
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

Re: altering the datatype of a column.

From
Oliver Elphick
Date:
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@lfix.co.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