---
title: "What exactly is happening when we make a field a primary key"  
description: "What exactly is happening when we make a field a primary key"  
author: "Anupam Mishra"  
published: 2016-02-08  
updated: 2016-02-09  
canonical: https://www.mindstick.com/forum/33966/what-exactly-is-happening-when-we-make-a-field-a-primary-key  
category: "database"  
tags: ["database", "database design", "database performance", "database security"]  
reading_time: 2 minutes  

---

# What exactly is happening when we make a field a primary key

Hi Everyone,I want know, when we make any [field](https://www.mindstick.com/forum/160867/does-mindstick-provide-training-for-field-marketing) a [primary key](https://www.mindstick.com/blog/214/primary-key) in a [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) then what is happening internally in database.Please can [anyone give me](https://answers.mindstick.com/qa/41194/can-anyone-give-me-some-high-and-low-points-of-each-of-the-four-first-presidential-administrations) a solution.Thank you.\
\

## Replies

### Reply by Manoj Bhatt

[Primary](https://www.mindstick.com/forum/33739/difference-between-primary-key-and-unique-key) Key: Primary key is a key that is selected as the primary key. Only one key within an entity is selected to be the primary key. This is the key that is allowed to migrate to other entities to define the relationships that exist among the entities. When the data model is instantiated into a physical database, it is the key that the system uses the most when accessing the table, or joining the tables together when selecting data.[WIKI] When we creating a primary key in a table such as below:\

```
SQL> CREATE TABLE STUDENTS (  ID INT                           NOT NULL,  NAME VARCHAR (20) NOT NULL,  AGE INT    NOT NULL,  ADDRESS CHAR (25),  PRIMARY KEY (ID)  );  
```

Here ID is a primary key. It will internally create a clustered index in a database.A clustered index will be created for that specific field.A clustered index sorts and stores the data rows in the table based on the index key values. Therefore only one clustered index can be created on each table because the data rows themselves can only be sorted in one order. A clustered index sorts and stores the data rows in the table based on the index key values. Therefore only one clustered index can be created on each table because the data rows themselves can only be sorted in one order. To create a different clustered index on the same table, change the Create as Clustered property setting on the existing clustered index before creating the second index.


---

Original Source: https://www.mindstick.com/forum/33966/what-exactly-is-happening-when-we-make-a-field-a-primary-key

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
