Re: Selecting newly added column returns empty but only when selecting with other columns in table

From: mrtruji <mrtruji(at)gmail(dot)com>
To: John R Pierce <pierce(at)hogranch(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Selecting newly added column returns empty but only when selecting with other columns in table
Date: 2015-11-27 03:11:50
Message-ID: CAJEV4po_qzuEwBByE=bQbtma66B=x_tx6uSVoB0ybhCdSnURfA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Used psycopg2 in python to create and fill in the table with the code
below:

cur.execute('alter table data add features_bin bytea;')

for x in features:
cur.execute('insert into data (features_bin) values (%s);',[x])
conn.commit()

features is a list variable of binary array objects.

On Thu, Nov 26, 2015 at 7:04 PM, John R Pierce <pierce(at)hogranch(dot)com> wrote:

> On 11/26/2015 4:13 PM, mrtruji wrote:
>
>>
>> Just added a new bytea type column to an existing psql table and
>> populated the column entirely with row data. Running into some strange
>> query results:
>>
>> When I select the newly added column by itself I get all the data as
>> expected:.....
>>
>>
> can you show the SQL commands you used to add this column and populate
> it? if you used INSERT to populate the new column, that would have
> inserted NEW rows, not modified existing rows. to modify the existing
> rows, you need to use UPDATE with a WHERE clause that selects the correct
> row to UPDATE with the data for your new field...
>
>
>
> --
> john r pierce, recycling bits in santa cruz
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2015-11-27 03:22:14 Re: Selecting newly added column returns empty but only when selecting with other columns in table
Previous Message mrtruji 2015-11-27 03:08:35 Re: Selecting newly added column returns empty but only when selecting with other columns in table