Difficulty: Easy
Correct Answer: Valid (indexes can enforce uniqueness and speed lookups by column values)
Explanation:
Introduction / Context: Indexes are auxiliary structures that improve query performance and, in the case of unique indexes or constraints, enforce uniqueness on key columns. Understanding this dual role clarifies why and when to create indexes in Oracle.
Given Data / Assumptions:
Concept / Approach: An index maps key values to row locations, allowing Oracle to locate rows efficiently without scanning entire tables. A UNIQUE index (often created automatically by a UNIQUE or PRIMARY KEY constraint) ensures that duplicate key values cannot be inserted. Non-unique indexes accelerate predicates, joins, and orderings but do not enforce uniqueness. Therefore, the statement that indexes both enforce uniqueness and enable fast retrieval is correct.
Step-by-Step Solution:
Create a UNIQUE constraint on a column; Oracle creates a unique index under the covers.Create a non-unique index to speed WHERE clauses, joins, and ORDER BY.Measure plans with EXPLAIN PLAN to confirm index usage.Avoid over-indexing writes; balance read and write needs.Verification / Alternative check: Attempt to insert duplicate keys under a UNIQUE constraint—Oracle raises an error, proving uniqueness enforcement through indexing.
Why Other Options Are Wrong:
Common Pitfalls: Creating too many indexes; forgetting to index selective foreign keys for join performance; assuming every query benefits from an index.
Final Answer: Valid (indexes can enforce uniqueness and speed lookups by column values)
Discussion & Comments