Re: Sub:column "" is of type bigint but expression is of type character varying

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rama Krishnan <raghuldrag(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Sub:column "" is of type bigint but expression is of type character varying
Date: 2022-08-17 15:07:43
Message-ID: acfd5710-933b-29ee-3490-fd694d7ad083@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/17/22 01:53, Rama Krishnan wrote:
> Hi All,
>

>
> i have purged the old data from orginal table when i am restoring the
> data from archive table into orignal table i am getting the error
>
>
> *insert into tickets select * from tickets_archive;*

The above depends on:

https://www.postgresql.org/docs/current/sql-insert.html

"The target column names can be listed in any order. If no list of
column names is given at all, the default is all the columns of the
table in their declared order; or the first N column names, if there are
only N columns supplied by the VALUES clause or query. The values
supplied by the VALUES clause or query are associated with the explicit
or implicit column list left-to-right.
"

If this is not the case then you can get mismatched columns where a
varchar value is being inserted into an integer field. Verify that the
table column order is the same for both tables.

>
>
>  column "*ticket_purchase_no*" is of type bigint but expression is of
> type character varying
> Regards
>
> A.Rama Krishnan

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-08-17 15:25:46 Re: Sub:column "" is of type bigint but expression is of type character varying
Previous Message Thomas Kellerer 2022-08-17 15:01:02 Re: Postgres question