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?
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.
精彩评论