Re: changing varchar to int

From: Ian Barwick <ian(at)2ndquadrant(dot)com>
To: Ankur Kaushik <ankurkaushik(at)gmail(dot)com>, pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: changing varchar to int
Date: 2015-07-23 09:41:02
Message-ID: 55B0B6AE.7060905@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 15/07/23 16:27, Ankur Kaushik wrote:
> Original column
>
>
>
> Column Type Modifiers
> model | character varying(50) | default NULL::character varying
>
>
> Required Column
>
> Model integer
>
>
> =========
> ALTER TABLE device ALTER COLUMN model TYPE integer USING (model::integer);
>
>
> getting below error
>
> ERROR: default for column "model" cannot be cast automatically to type integer

You'll need to drop the column default and re-add it after converting the
column.

Regards

Ian Barwick

--
Ian Barwick http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, RemoteDBA, Training & Services

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Matheus de Oliveira 2015-07-23 12:55:07 Re: changing varchar to int
Previous Message Ankur Kaushik 2015-07-23 07:27:03 changing varchar to int