Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unique Index Implicit or Explicit Creation?

2776946May 6 2015 — edited May 6 2015

I am reading Steve O'hearn 1zo-047 textbook  p.404 it mentions:

A unique index is one that helps ensure that a column in a table will contain unique

information. The syntax for creating a unique index is as follows:

CREATE UNIQUE INDEX IX_EMP_SSN ON EMPLOYEES(SSN);

This is different from the UNIQUE constraint that you can apply to a column on

a table. However, note that if you create a PRIMARY KEY or UNIQUE constraint

on a table, a unique index will automatically be created along with the constraint.

Note that the UNIQUE constraint is more self-documenting within the database.

That being said, Oracle Corporation formally recommends the creation of unique

indexes to enforce uniqueness in a column, for better results in query performance.

Okay, so the bolded area has me a bit confused.  Is this saying that Unique Constraint indexes are geared more towards self-documentation purposes so we should create the Unique Index explicitly?

Or is it simply mentioning that because because the UK/PK constraints self-document it is recommended  to create such Constraints/Indexes.

Sorry for what may seem like a vague question, I haven't had the chance to work with index optimization, nor would I be able to efficiently navigate such a task at this point, so I thought I'd ask for tips on the forums..

Thanks.

This post has been answered by Dom Brooks on May 6 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2015
Added on May 6 2015
8 comments
2,358 views