Re: how to overwrite tuples in a table - Mailing list pgsql-novice

From Sean Davis
Subject Re: how to overwrite tuples in a table
Date
Msg-id F8C4DB9C-026B-11D9-B942-000A95D7BA10@mail.nih.gov
Whole thread Raw
In response to how to overwrite tuples in a table  ("Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar.Pyatalo@honeywell.com>)
List pgsql-novice
Are you looking for UPDATE?

http://www.postgresql.org/docs/7.4/static/sql-update.html

Sean

UPDATE pointattributes SET strvalue='Good Morning', numvalue=9 WHERE
pointid=7 AND attributeid=50;

On Sep 9, 2004, at 10:13 AM, Pradeepkumar, Pyatalo (IE10) wrote:

> Hi,
>  
> I have a table
> pointattributes(pointid,attributeid,strvalue,numvalue)......where
> pointid and attributeid are foreign keys refering to other tables. Now
> how can i overwrite tuples in this table. To make it simpler,
> pointid        attributeid        strvalue        numvalue
> ----------------------------------------------------------------------
> 4                    45                    hello                3
> 7                    50                    hai                   9
>  
> I want this table to retain the latest data.....
> so if i say insert into pointattributes values(7,50,'Good
> Morning',10), it should overwrite the previous tuple with this latest
> one. Is there a way to do that.
> One simple way is to check if there are any tuples with the given
> pointid and attributeid, if a tuple exists delete the tuple with the
> pointid and attribute(the combination is unique) and then insert the
> new tuple.
> But is there any better way to do that.
>  
> Thanks in advance.
>  
>
> With Best Regards
> Pradeep Kumar P J
>


pgsql-novice by date:

Previous
From: "Pradeepkumar, Pyatalo (IE10)"
Date:
Subject: how to overwrite tuples in a table
Next
From: Jake Stride
Date:
Subject: Table locks