Re: SQL Newbie Question

From: btober(at)ct(dot)metrocast(dot)net
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL Newbie Question
Date: 2007-01-25 15:54:12
Message-ID: 45B8D2A4.9000601@ct.metrocast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ron Johnson wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 01/25/07 09:30, Inoqulath wrote:
>
>> Hello Folks
>>
>> Have a look at this Table:
>>
>> CREATE TABLE foo(
>> id serial,
>> a_name text,
>> CONSTRAINT un_name UNIQUE (a_name));
>>
>> Obviously, inserting a string twice results in an error ...is there any "conflict algorithm" (SQLite:"INSERT OR
>> [IGNORE|ABORT] INTO foo [...]")?...
>>
> No.
>
> Unique \U*nique"\, a. [F. unique; cf. It. unico; from L. unicus,
> from unus one. See {One}.]
> Being without a like or equal; ...
>

I think he is not asking "How do I insert duplicate rows into a
unique-constrained column?", but rather that he wants to have the insert
transaction proceed successfully, ignoring the duplicates, i.e., the
resulting inserted rows will number less than the original source rows
by exactly the subset of duplicate source rows.

My suggestion would be to load the data into an unconstrained temporary
table, then select distinct from that for insertion into your actual
working table.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2007-01-25 15:55:18 Re: Problem with result ordering
Previous Message Ron Johnson 2007-01-25 15:48:04 Re: column limit