<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unique compound indexes in Oracle 8i and 9i ???? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034513#M910703</link>
    <description>Use the following sql to check the duplication of emial field(including email fiels with null value):&lt;BR /&gt;select distinct(email),count(email) &lt;BR /&gt;from table &lt;BR /&gt;having count(email) &amp;gt; 1 &lt;BR /&gt;group by email; &lt;BR /&gt;I think you may find duplicates of the non-null columns. &lt;BR /&gt;&lt;BR /&gt;Do you try to create index on email field only? Take a try at this.&lt;BR /&gt;&lt;BR /&gt;Attached article may help. &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 28 Jul 2003 00:29:05 GMT</pubDate>
    <dc:creator>twang</dc:creator>
    <dc:date>2003-07-28T00:29:05Z</dc:date>
    <item>
      <title>Unique compound indexes in Oracle 8i and 9i ????</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034511#M910701</link>
      <description>&lt;BR /&gt;I am trying to create a unique compound index on 8i and 9i.&lt;BR /&gt;&lt;BR /&gt;I have a table with a unique index on field email, and no index on field empid.   I need a compound unique index, so, I figure that if I create a unique index on these two fields, they would ALWAYS be unique, for the email is already a unique indexed field.&lt;BR /&gt;&lt;BR /&gt;so, I did :&lt;BR /&gt;&lt;BR /&gt;create unique index id_name_uidx on table_name(email,empid) .....&lt;BR /&gt;&lt;BR /&gt;and got the error :&lt;BR /&gt;&lt;BR /&gt;ERROR at line 1:&lt;BR /&gt;ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found&lt;BR /&gt;&lt;BR /&gt;I know the email is unique, and know that the empid is not, for when I check for dups, I find a bunch !!!&lt;BR /&gt;&lt;BR /&gt;select distinct(empid),count(empid)&lt;BR /&gt;from table&lt;BR /&gt;having count(empid) &amp;gt; 1&lt;BR /&gt;group by empid;&lt;BR /&gt;&lt;BR /&gt;Now, the questions that I have are :&lt;BR /&gt;&lt;BR /&gt;In order to create a compound unique index, does all fields need to be unique ? ( this kind of defeats the purpose for compound indexes ).  If not, what is happening here ?  Maybe because both fields can have NULL elements on it, and the duplicate keys are they NULL,NULL ????  I do not get it !!!&lt;BR /&gt;&lt;BR /&gt;Also, how do I check for duplicates on these combined fields ?  I can use the query above for individual field queries, but If I need to check for duplciates on (email,empid0), how do I do it ?&lt;BR /&gt;&lt;BR /&gt;    Thanks,&lt;BR /&gt;&lt;BR /&gt;Henrique</description>
      <pubDate>Sun, 27 Jul 2003 17:00:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034511#M910701</guid>
      <dc:creator>Henrique Silva_3</dc:creator>
      <dc:date>2003-07-27T17:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Unique compound indexes in Oracle 8i and 9i ????</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034512#M910702</link>
      <description>The uniqueness applies to the combined columns which comprise the compound index rather than the indiviual columns. The catch is that the unique constraint does not apply to NULL columns; for this reason, it is a very good idea to apply the NOT NULL constraint to all components of a composite index.&lt;BR /&gt;</description>
      <pubDate>Sun, 27 Jul 2003 18:17:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034512#M910702</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-07-27T18:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unique compound indexes in Oracle 8i and 9i ????</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034513#M910703</link>
      <description>Use the following sql to check the duplication of emial field(including email fiels with null value):&lt;BR /&gt;select distinct(email),count(email) &lt;BR /&gt;from table &lt;BR /&gt;having count(email) &amp;gt; 1 &lt;BR /&gt;group by email; &lt;BR /&gt;I think you may find duplicates of the non-null columns. &lt;BR /&gt;&lt;BR /&gt;Do you try to create index on email field only? Take a try at this.&lt;BR /&gt;&lt;BR /&gt;Attached article may help. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Jul 2003 00:29:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034513#M910703</guid>
      <dc:creator>twang</dc:creator>
      <dc:date>2003-07-28T00:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Unique compound indexes in Oracle 8i and 9i ????</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034514#M910704</link>
      <description>Add to my above reply, I suggest you try to add a primary key constraint on the table and use the exceptions into clause. This will give you the exact rows it is having troubles with:&lt;BR /&gt;SQL&amp;gt; alter table emp add unique (empid, email) &lt;BR /&gt;2 exceptions into exceptions; &lt;BR /&gt;alter table emp add unique (empid, emial) &lt;BR /&gt;* &lt;BR /&gt;ERROR at line 1: &lt;BR /&gt;ORA-02299: cannot enable (SCOTT.SYS_C002463) - duplicate keys found &lt;BR /&gt;SQL&amp;gt; l &lt;BR /&gt;1 select empid, email from emp, exceptions &lt;BR /&gt;2* where emp.rowid = exceptions.row_id &lt;BR /&gt;SQL&amp;gt; / &lt;BR /&gt;&lt;BR /&gt;EMPNO DEPTNO &lt;BR /&gt;---------- ---------- &lt;BR /&gt;30 &lt;BR /&gt;30 &lt;BR /&gt;</description>
      <pubDate>Mon, 28 Jul 2003 00:39:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034514#M910704</guid>
      <dc:creator>twang</dc:creator>
      <dc:date>2003-07-28T00:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unique compound indexes in Oracle 8i and 9i ????</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034515#M910705</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;Note that to enforce uniqueness, you need a constraint and the constraint makes use of an index (be it a UNIQUE index or an index that allows for duplicates) to make this enforcement go faster. &lt;BR /&gt;&lt;BR /&gt;To check for duplicates use the following query:&lt;BR /&gt;select email,empid, count(*)&lt;BR /&gt;from table_name&lt;BR /&gt;having count(*) &amp;gt;1&lt;BR /&gt;group by email, empid;&lt;BR /&gt;&lt;BR /&gt;hope this helps!&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Yogeeraj</description>
      <pubDate>Mon, 28 Jul 2003 03:54:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unique-compound-indexes-in-oracle-8i-and-9i/m-p/3034515#M910705</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2003-07-28T03:54:47Z</dc:date>
    </item>
  </channel>
</rss>

