What's the difference between a Primary Key and a Unique Key?
What's the difference between a Primary Key and a Unique Key?
The primary key and unique key are both essential constraints in relational databases, but they serve different purposes and have distinct characteristics.
A primary key is a column or a set of columns in a table that uniquely identifies each row in that table. The primary key enforces entity integrity by ensuring that no two rows have the same primary key value and that the primary key column(s) do not contain NULL values. Here are the key features of a primary key:
A unique key, like a primary key, ensures that the values in a column or a set of columns are unique across the table. However, it has some differences from a primary key:
middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào