update entire table (with PostGreSQL alone)?

From: "yruhn" <yruhn(at)xdh(dot)nl>
To: <pgsql-general(at)postgresql(dot)org>
Subject: update entire table (with PostGreSQL alone)?
Date: 2003-08-22 08:48:39
Message-ID: 200308221048.AA48889986@xdh.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear anyone,

I wish to update an entire table with just using (PostGre)SQL (=preferably without resorting to C, Python or so). Can I? If so how?

For example, I want to update/replace table:

a | b | c
---+---+---
1 | 2 | 3
4 | 5 | 6
7 | 8 | 9

with table:

a | b | c
---+---+---
1 | 2 | 2
4 | 5 | 6
9 | 0 | 0

So, I wish to:
1- update every data point in the table (based on the UNIQUE column 'a' (=PRIMARY KEY)), and if this value of a is not present (such as for instance value 9: 9,0,0),I wish to;
2- insert a new row with data points
3- and I want to delete old rows that are not used present in the new table (such as row 7 : 7,8,9)

How can I update an entire table with just using (PestGre)SQL?

Lots of thanks for any help anyone can give me,

Wiliam Knobbel, PhD-Student

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Diogo Biazus 2003-08-22 08:57:06 Strange problem with PL/PgSQL stored procedures
Previous Message Shridhar Daithankar 2003-08-22 08:36:48 Re: [GENERAL] [pgsql-advocacy] Need concrete "Why Postgres