📞 0339-0387701 (WhatsApp) Contact

« Back to Database & Data Handling (NCCIA)

If a table has a PRIMARY KEY on StudentID, what happens on inserting a second row with the same StudentID?

A. Both rows are kept with a warning
B. The insert fails because the key must be unique ✅
C. The StudentID is set to NULL
D. The old row is replaced

Correct Answer: B. The insert fails because the key must be unique

Explanation

  • A duplicate primary key value violates uniqueness and the insert is rejected.
  • The existing row is unchanged.