change data type from text to numeric

From: Daniel Torres <nobeeakon(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: change data type from text to numeric
Date: 2014-11-26 21:40:53
Message-ID: CAJGorGy=ckXxfHXPqQe-rsUq5BBmpsWM4qZ14OyTZE3Nv-mw+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi everyone,

sorry to bother you with a simple question, (I'm a new user of postgresql),
how do I change the data type of a column of text, to numeric or integer?

I tried with:

ALTER TABLE table_name
ALTER COLUMN col_name TYPE integer
;

It gives me a mistake
ERROR: la columna no puede convertirse automáticamente al tipo integer
SUGERENCIA: Especifique una expresión USING para llevar a cabo la
conversión.

translation: the column can't be converted automatically to type integer
.... specify an expression using USING to make the conversion.

I also tried on pgadmin3, but couldn't found how to do it...

thanks,
Daniel

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G Johnston 2014-11-26 22:03:00 Re: change data type from text to numeric
Previous Message David Johnston 2014-11-26 21:04:23 Re: Range type bounds