Re: unique rows

From: Kaloyan Iliev <news1(at)faith(dot)digsys(dot)bg>
To: "TJ O'Donnell" <tjo(at)acm(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: unique rows
Date: 2006-09-21 07:33:57
Message-ID: 45124065.2030406@faith.digsys.bg
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

HI,

1. You can try to create a trigger before insert to check if the new row
exists in the table and if it does to cancel the insert.
2. Or create a UNIQUE INDEX on all the columns which will throw error if
you try to insert duplicate rows in the table.
Then in the apllication software just catch the error and move on with
the next insert.

I hope I helped.

Regards,

Kaloyan Iliev

TJ O'Donnell wrote:

> I want to make a table that has unique rows - no problem.
> Create Table x (smarts Varchar Unique);
>
> I have input data that has many duplicates and until now
> I was creating a temp table allowing duplicates, and then
> Insert into x (smarts) select distinct smarts from tmpx;
> This is now failing when I have hundreds of millions of
> rows, running out of temp space (while trying to sort to
> accomplish the distinct?)
>
> So, is there a way (a constraint, a check?) that will simply
> REJECT a duplicate when I insert the raw data directly into x
> rather than FAILING on an error as it does
> with the unique constraint above?
>
> Thanks,
> TJ O'Donnell
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Schaber 2006-09-21 07:46:11 Re: unique rows
Previous Message David Klugmann 2006-09-21 06:36:02 Unsubscribe