1

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

  • Id
  • Name
  • Surname
  • DateOfBirth
  • DateOfAdmission
  • DateOfPassout

This table have following primary key:

  • Id
  • Name
  • Surname
  • DateOfAdmission

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?

1
  • Does your primary key really need four columns? Judging by the names, it looks like Id should be the primary key (I presume it is always unique). Understand that if your primary key really does consist of four columns, you will end up with a lot of columns in other tables for foreign key constraints. Commented Jan 13, 2011 at 9:27

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.