---
title: "What's the difference between a primary key and a unique key?"  
description: "What's the difference between a primary key and a unique key?"  
author: "Anonymous User"  
published: 2015-01-16  
updated: 2020-09-16  
canonical: https://www.mindstick.com/interview/2275/what-s-the-difference-between-a-primary-key-and-a-unique-key  
category: "mssql server"  
tags: ["sql server 2012"]  
reading_time: 1 minute  

---

# What's the difference between a primary key and a unique key?

Both primary key and unique key enforces uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.

## Answers

### Answer by Anonymous User

Both primary key and unique key enforces uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.


---

Original Source: https://www.mindstick.com/interview/2275/what-s-the-difference-between-a-primary-key-and-a-unique-key

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
