What is difference between primary index and secondary index exactly?

MysqlDatabaseOracleIndexing

Mysql Problem Overview


Can any one tell me what's the exact difference between Primary index & Secondary index? What are the different indexes that comes under category of primary & secondary index? And what's advantages of using primary index over secondary index & vice versa?

Mysql Solutions


Solution 1 - Mysql

Primary index:

A primary index is an index on a set of fields that includes the unique primary key for the field and is guaranteed not to contain duplicates. Also Called a Clustered index. eg. Employee ID can be Example of it.

Secondary index:

A Secondary index is an index that is not a primary index and may have duplicates. eg. Employee name can be example of it. Because Employee name can have similar values.

The primary index contains the key fields of the table. The primary index is automatically created in the database when the table is activated. If a large table is frequently accessed such that it is not possible to apply primary index sorting, you should create secondary indexes for the table.

The indexes on a table have a three-character index ID. '0' is reserved for the primary index. Customers can create their own indexes on SAP tables; their IDs must begin with Y or Z.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3099630View Question on Stackoverflow
Solution 1 - MysqlKumod SinghView Answer on Stackoverflow