title: How to determine which UNIQUE index enforces the PRIMARY KEY in Oracle
body: <p>Given a table with two unique indexes, as shown below, how does one determine which unique index corresponds to the PRIMARY KEY, as opposed to other UNIQUE indexes on that table?</p>
  
  <p>The user_indexes and user_ind_columns do not seem to carry that information. Thanks, --DD</p>
  
  <p>PS: Short of explicitly naming the indexes and using a naming convention of course.</p>
  
  <pre><code>SQL&gt; create table tt (id number not null primary key, name varchar2(64 char) not null unique, info varchar2(4000));
  
  SQL&gt; create index tt_idx on tt(info);
  
  SQL&gt; select INDEX_NAME, INDEX_TYPE, UNIQUENESS from user_indexes where TABLE_NAME='TT';
  
  INDEX_NAME           INDEX_TYPE                  UNIQUENES
  -------------------- --------------------------- ---------
  SYS_C0029541         NORMAL                      UNIQUE
  SYS_C0029542         NORMAL                      UNIQUE
  TT_IDX               NORMAL                      NONUNIQUE
  
  SQL&gt; select * from user_ind_columns where TABLE_NAME='TT';
  
  INDEX_NAME           TABLE_NAME           COLUMN_NAME  COLUMN_POSITION COLUMN_LENGTH CHAR_LENGTH DESC
  -------------------- -------------------- ------------ --------------- ------------- ----------- ----
  SYS_C0029541         TT                   ID                         1            22           0 ASC
  SYS_C0029542         TT                   NAME                       1           256          64 ASC
  TT_IDX               TT                   INFO                       1          4000        4000 ASC
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>Here's the result of running Florin's query, which clearly shows which index enforces the <strong>P</strong> RIMARY KEY:</p>
  
  <pre><code>SQL&gt; select constraint_name, constraint_type, index_name from user_constraints where table_name='TT';
  
  CONSTRAINT_NAME                C INDEX_NAME
  ------------------------------ - --------------------
  SYS_C0029539                   C
  SYS_C0029540                   C
  SYS_C0029541                   P SYS_C0029541
  SYS_C0029542                   U SYS_C0029542
  </code></pre>