Re: changing varchar to int - Mailing list pgsql-admin

From Ian Barwick
Subject Re: changing varchar to int
Date
Msg-id 55B0B6AE.7060905@2ndquadrant.com
Whole thread Raw
In response to changing varchar to int  (Ankur Kaushik <ankurkaushik@gmail.com>)
Responses Re: changing varchar to int
List 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


pgsql-admin by date:

Previous
From: Ankur Kaushik
Date:
Subject: changing varchar to int
Next
From: Matheus de Oliveira
Date:
Subject: Re: changing varchar to int