Difference between Primary Key and Unique Key
Primary Key | Unique Key |
---|---|
Each value in the primary key column must be unique. | Each value in the unique key column must be unique, but a table can have multiple unique keys. |
The primary key column cannot contain NULL values. | The unique key column allows one NULL value. |
A table can have only one primary key. | A table can have more than one unique key. |
By default, a primary key creates a clustered index (affects physical storage order of data). | The default index for a unique key is non-clustered. |
MySQL Primary Key
MySQL is an open-source relational database management system that uses Structured Query Language (SQL) to manipulate databases. It stores data in a table format and to uniquely identify each record in a table, we require a Primary Key.
In this article, we will learn how to add, modify, and remove the primary key in MySQL tables with examples.
Contact Us