employer cover photo
employer logo
employer logo

Tata Consultancy Services

Part of Tata Group

Engaged Employer

Tata Consultancy Services Interview Question

Can you explain the difference between a primary key and a unique key in SQL, and can a table have multiple unique keys?

Interview Answer

Anonymous

Jul 8, 2026

Yes, a table can have multiple unique keys but only one primary key. The main difference is that a primary key uniquely identifies a row and cannot accept NULL values, whereas a unique key prevents duplicates but can accept a single NULL value depending on the database system.