1. Home
  2. Computer Science MCQs
  3. MySQL
  4. On executing the DELETE command, if you get an error…

Added 19 Jan 2024

On executing the DELETE command, if you get an error “foreign key constraint” – what does it imply?

  1. Foreign key not defined
  2. Table is empty
  3. Connectivity issue
  4. Data is present in the other table Correct answer

Correct answer

D. Data is present in the other table

16 views

MCQSEXAM

Explanation

The error means data is present in the other table: rows in a child table still reference the row you are trying to delete through a foreign key.

MySQL blocks the delete to preserve referential integrity. Either delete the child rows first or define the foreign key with ON DELETE CASCADE.

Want more practice? Try the full set of Database Management Systems MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More MySQL MCQs

Practise all MySQL MCQs

Similar MCQs