
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
What is the difference between MySQL PRIMARY KEY and UNIQUE constraint?
The following table will provide us the differences between PRIMARY KEY and UNIQUE constraint −
PRIMARY KEY | UNIQUE Constraint |
---|---|
1. Only one Primary key can be created on a table. | 1. More than one UNIQUE Constraints can be added to a table. |
2. Primary key creates clustered index by default. | 2. UNIQUE Constraint creates a non-clustered index by default. |
3. We cannot insert null values in the column which is defined as PRIMARY KEY. | 3. We can insert null values in the column having a UNIQUE constraint. |
- Related Articles
- Difference between Primary Key and Unique key
- Difference between Primary Key and Candidate key
- Primary key Vs Unique key
- Difference Between Primary and Candidate Key
- Difference between Primary key and Foreign key in Database
- Difference Between Primary key and Foreign key in DBMS
- Difference between Primary key and Foreign key in SQL Database
- How can we apply the PRIMARY KEY constraint to the field of an existing MySQL table?
- How can we remove PRIMARY KEY constraint from a column of an existing MySQL table?
- Is the primary key automatically indexed in MySQL?
- What happens if I will try to drop PRIMARY KEY constraint from the AUTO_INCREMENT column?
- Dropping Unique constraint from MySQL table?
- Remove Primary Key in MySQL?
- Reset Primary Key in MySQL
- In case of FOREIGN KEY constraint, what kind of relationship is there between MySQL parent and child tables?

Advertisements