Someone asked me this question on an interview...
The main difference is that the primary key column can only be created when you create/add the table or column, not later. The primary key constraint you can add any time later.
Primary key can store null value, whereas a unique key cannot store null value.
A primary key is a column, or a combination of columns, that can uniquely identify a row. It is a special case of unique key. A table can have at most one primary key, but more than one unique key. When you specify a unique key on a column, no two distinct rows in a table can have the same value.
Primary keys can't be null. Unique keys can.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With