Re: Cast char to number

Поиск
Список
Период
Сортировка
Искать
От
Daniel Verite
Тема
Re: Cast char to number
Дата
Msg-id
ab530d33-abda-44c0-9548-6e1cef0a3c0a@mm
Ответ на
Re: Cast char to number (Raymond O'Donnell)
Список
Дерево обсуждения
Cast char to number Christine Penner <christine@ingenioussoftware.com>
Re: Cast char to number Bill Moran <wmoran@potentialtech.com>
Re: Cast char to number Christine Penner <christine@ingenioussoftware.com>
Re: Cast char to number Raymond O'Donnell <rod@iol.ie>
Re: Cast char to number Bill Moran <wmoran@potentialtech.com>
Re: Cast char to number Richard Huxton <dev@archonet.com>
Re: Cast char to number "Joshua D. Drake" <jd@commandprompt.com>
Re: Cast char to number "Joshua D. Drake" <jd@commandprompt.com>
Re: Cast char to number Bill Moran <wmoran@potentialtech.com>
Re: Cast char to number Tom Lane <tgl@sss.pgh.pa.us>
Re: Cast char to number Scott Marlowe <scott.marlowe@gmail.com>
Re: Cast char to number Richard Huxton <dev@archonet.com>
Re: Cast char to number Scott Marlowe <scott.marlowe@gmail.com>
Re: Cast char to number "Joshua D. Drake" <jd@commandprompt.com>
Re: Cast char to number "Joshua D. Drake" <jd@commandprompt.com>
Re: Cast char to number "Daniel Verite" <daniel@manitou-mail.org>
	Raymond O'Donnell wrote:

> (i)   Create a new column of type numeric or integer as appropriate.
> (ii)  update your_table set new_column = CAST(trim(both ' 0' from
> old_column) as numeric)
> (iii) Drop the old column, as well as any constraints depending on it.
> (iv)  Rename the new column to the same name as the old column
> (v)   Recreate any of the constraints dropped in step (iii).

Or try in a single step:
ALTER TABLE tablename ALTER column column_name
  TYPE numeric USING column_name::numeric;
(replace numeric by the desired type if it's not numeric).

Best regards,
-- 
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org
В списке pgsql-general по дате отправления
От: Richard Huxton
Дата:
Сообщение: Re: Cast char to number
От: Joshua D. Drake
Дата:
Сообщение: Re: Cast char to number
FAQ