Q3. What is the difference between a primary key and a unique key?
A primary key uniquely identifies each row: its values are unique and can't be NULL, and a table has at most one. A unique key also enforces uniqueness but allows a single NULL, and a table can have several of them for different business rules.
Both create a supporting index automatically. The primary key is the row's identity; unique keys enforce business rules like 'no two employees share an email'.
CREATE TABLE employees (
emp_id NUMBER PRIMARY KEY, -- unique, not null, one per table
email VARCHAR2(100) UNIQUE, -- unique, allows one NULL
name VARCHAR2(100) NOT NULL
);Key point: The trap is saying a unique key can't be NULL. It can hold one NULL, which is exactly what separates it from a primary key.