how to overwrite tuples in a table

Поиск
Список
Период
Сортировка
От Pradeepkumar, Pyatalo (IE10)
Тема how to overwrite tuples in a table
Дата
Msg-id 77ED2BF75D59D1439F90412CC5B1097411686849@ie10-sahara.hiso.honeywell.com
обсуждение исходный текст
Ответы Re: how to overwrite tuples in a table  (Sean Davis <sdavis2@mail.nih.gov>)
Список pgsql-novice
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 по дате отправления:

Предыдущее
От: Gaetano Mendola
Дата:
Сообщение: Re: Cast
Следующее
От: Sean Davis
Дата:
Сообщение: Re: how to overwrite tuples in a table