Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

difference between primary key and primary index

Former Member
0 Kudos

Dear All,

Hi... .Could you pls tell me the difference between primary key and primary index.

Thanks...

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Primary Key : It is one which makes an entry of the field unique.No two distinct rows in a table can have the same value (or combination of values) in those columns.

Eg: first entry is 111, if you again enter value 111 , it doesnot allow 111 again. similarly for the strings or characters or numc etc. Remember that for char or numc or string 'NAME' is not equal to 'name'.

Primary Index: this is related to the performance .A database index is a data structure that improves the speed of operations in a table. Indices can be created using one or more columns, providing the basis for both rapid random lookups and efficient ordering of access to records. The disk space required to store the index is typically less than the storage of the table (since indices usually contain only the key-fields according to which the table is to be arranged, and excludes all the other details in the table), yielding the possibility to store indices into memory from tables that would not fit into it. In a relational database an index is a copy of part of a table. Some databases extend the power of indexing by allowing indices to be created on functions or expressions. For example, an index could be created on upper(last_name), which would only store the uppercase versions of the last_name field in the index.

In a database , we may have a large number of records. At the time of retrieving data from the database based on a condition , it is a burden to the db server. so whenever we create a primary key , a primary index is automatically created by the system.

If you want to maintain indices on other fields which are frequently used in where condition then you can create secondary indices.

Reward points if helpful.

Thanks,

Sirisha..

4 REPLIES 4

Former Member
0 Kudos

PRIMARY INDEX:

This is aumatically generated the movement we create a database table.It is only for the key fields in the table. The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.

PRIMARY KEY:

Primary key is mandatory.it avoid the duplicate of data.for ex (student rollno, material no, employee id)it should be a unique.

when you create the foreign key table . you want to refer only the primary key field of the reference table(checked table)

when you create the foreign key in the particular table before it should be one primary key. you can create no of primary keys in one table. by defaultly the one primary index should be created for that table.

Former Member
0 Kudos

hi,

Check out the below related threads

Regards,

Santosh

Former Member
0 Kudos

Primary Key: that is used for uniquely identified a perticular row of a database table .

Primary INDEX: That is used for getting a index from a database table and that indexing is done on unique based.

Former Member
0 Kudos

Hi,

Primary Key : It is one which makes an entry of the field unique.No two distinct rows in a table can have the same value (or combination of values) in those columns.

Eg: first entry is 111, if you again enter value 111 , it doesnot allow 111 again. similarly for the strings or characters or numc etc. Remember that for char or numc or string 'NAME' is not equal to 'name'.

Primary Index: this is related to the performance .A database index is a data structure that improves the speed of operations in a table. Indices can be created using one or more columns, providing the basis for both rapid random lookups and efficient ordering of access to records. The disk space required to store the index is typically less than the storage of the table (since indices usually contain only the key-fields according to which the table is to be arranged, and excludes all the other details in the table), yielding the possibility to store indices into memory from tables that would not fit into it. In a relational database an index is a copy of part of a table. Some databases extend the power of indexing by allowing indices to be created on functions or expressions. For example, an index could be created on upper(last_name), which would only store the uppercase versions of the last_name field in the index.

In a database , we may have a large number of records. At the time of retrieving data from the database based on a condition , it is a burden to the db server. so whenever we create a primary key , a primary index is automatically created by the system.

If you want to maintain indices on other fields which are frequently used in where condition then you can create secondary indices.

Reward points if helpful.

Thanks,

Sirisha..