Um Dein Ziel zu erreichen, wurde UNIQUE INDEXE erfunden. Um eine bereits versaute Tabelle zu bereinigen, mußt man halt die falschen löschen, z.B. so:
test=# create table versaut (id text, lang text);
CREATE TABLE
test=*# copy versaut from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> a bla
>> a foo
>> a blub
>> b bar
>> c foobar
>> \.
test=*# delete from versaut where (id,lang) not in (select distinct on (id) id, lang from versaut order by id, lang);
DELETE 2
test=*# select * from versaut ;
id | lang
----+--------
a | bla
b | bar
c | foobar
(3 rows)
Und nicht vergessen:
test=*# create UNIQUE INDEX idx_versaut on versaut(id);
CREATE INDEX