Vaibhav
Vaibhav

Reputation: 11

Oracle Table Index creation

I created a table named STUDENT. It has the following columns:

This table have following primary key:

Do I need to create an index another index of column Id, Name if want to query this table providing input just Id and Name?

Upvotes: 1

Views: 147

Answers (1)

OMG Ponies
OMG Ponies

Reputation: 332531

An index isn't necessary for queries.
An index has the potential to speed up queries if the index can be used, but will slow down INSERT/UPDATE/DELETE statements.

I'm not clear when Oracle started, but Oracle 10g+ will automatically create an index when a primary key is defined for a table. That index will match the column(s) that make up the primary key. Being that the id and name columns are part of the primary key, the pair is guaranteed to be unique and I don't see the need to create an additional covering index.

Upvotes: 2

Related Questions