Re: data integrity and inserts

From: "Ian Harding" <iharding(at)tpchd(dot)org>
To: <leknarf(at)pacbell(dot)net>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: data integrity and inserts
Date: 2004-12-01 18:20:52
Message-ID: s1ad9b33.008@MAIL.TPCHD.ORG
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

CREATE UNIQUE INDEX uidx_thename ON names(the_name);

Should prevent duplicates.

Ian Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
iharding(at)tpchd(dot)org
Phone: (253) 798-3549
Pager: (253) 754-0002

>>> Scott Frankel <leknarf(at)pacbell(dot)net> 12/01/04 10:11 AM >>>

I want to ensure data integrity when inserting into a table, preventing
multiple
entries of identical rows of data.

Does this call for using a trigger?
How would triggers perform a query to test if data already exists in
the table?

(The doco outlines how triggers perform tests on NEW data inserted into
a
table; but I haven't found anything on data already extant.)

Thanks in advance!
Scott

sample table:

CREATE TABLE names (the_id SERIAL PRIMARY KEY, the_name text);

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2004-12-01 18:21:29 Re: data integrity and inserts
Previous Message Scott Frankel 2004-12-01 18:11:36 data integrity and inserts