Skip site navigation (1) Skip section navigation (2)

Re: how to overwrite tuples in a table

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: "Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how to overwrite tuples in a table
Date: 2004-09-09 14:24:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Are you looking for UPDATE?


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

In response to

pgsql-novice by date

Next:From: Jake StrideDate: 2004-09-09 15:10:23
Subject: Table locks
Previous:From: Pradeepkumar, Pyatalo (IE10)Date: 2004-09-09 14:13:50
Subject: how to overwrite tuples in a table

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group