Category: MySQL

Difference between primary key and unique key


Primary Key is used to identify a row (record) in a table, whereas Unique-key is to prevent duplicate values in a column (with the exception of a null entry). By default SQL-engine creates Clustered Index on primary-key if not exists and Non-Clustered Index on Unique-key. Primary key does not include Null values, whereas Unique-key can. … Continue reading