From: | David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: change data type from text to numeric |
Date: | 2014-11-26 22:03:00 |
Message-ID: | 1417039380861-5828438.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Daniel Torres wrote
> 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
There is a serviceable example of the USING variation of ALTER TABLE ..
ALTER COLUMN in the documentation.
http://www.postgresql.org/docs/9.3/interactive/sql-altertable.html
The simplest conversion is simply "col_name::numeric"...
David J.
--
View this message in context: http://postgresql.nabble.com/change-data-type-from-text-to-numeric-tp5828434p5828438.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Bill Moran | 2014-11-26 22:07:30 | Re: change data type from text to numeric |
Previous Message | Daniel Torres | 2014-11-26 21:40:53 | change data type from text to numeric |