Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: How do I locate duplicate rows

Re: How do I locate duplicate rows

From: descmath <kevind_at_descmath.com>
Date: Thu, 30 Nov 2000 04:30:07 -0000
Message-ID: <t2blufb97e461@corp.supernews.com>

I usually do this with a WHERE EXISTS clause and check for rows in the table with the same value in the column but a different rowid, for example, if I want to find dups in my column, I write the query:

SELECT count(*)
  FROM My_Table a
 WHERE EXISTS (SELECT 'x'

                 FROM My_Table b
                WHERE a.some_column = b.some_column
                  and a.rowid != b.rowid);

This query is slow on large tables. When I have a large table, I might right a procedure to find the dups.

Anthony Valentine wrote:
>
> Hello All!
>
> I am trying to add a unique constraint to a table, but I get the
> following error:
>
> ORA-02299: cannot validate (ORACLE.LOS160MASTER_UK) - duplicate keys
> found
>
> Is there any way to get Oracle to tell me which rows contain the
> duplicate keys?
>
>
> Thanks in advance!
>
> Anthony Valentine
>
>

--
Posted via CNET Help.com
http://www.help.com/
Received on Wed Nov 29 2000 - 22:30:07 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US