Re: column "id" is of type integer but expression is of type character

From: Richard Huxton <dev(at)archonet(dot)com>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: column "id" is of type integer but expression is of type character
Date: 2009-01-08 19:16:22
Message-ID: 49665106.4070102@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrus wrote:
> Commands:
>
> create temp table test ( id int, baas char(10) );
> create temp table lisa ( id int, baas char(10) );
> alter table lisa drop column id;
> INSERT INTO test SELECT * FROM lisa;
> drop table lisa;
>
> Cause error
>
> ERROR: column "id" is of type integer but expression is of type character
> HINT: You will need to rewrite or cast the expression.

> How to fix ?

Don't use SELECT * - list the columns you want to insert. I can't think
why you would do that (you'll end up with nulls in the id column) but it
will work.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-01-08 19:18:10 Re: column "id" is of type integer but expression is of type character
Previous Message Raymond O'Donnell 2009-01-08 19:14:08 Re: column "id" is of type integer but expression is of type character