Vidyalelo
MySQL · Q911

MySQL

Programming · MySQL · question 911

Q911

In the following MySQL command how many rows will be deleted? DELETE person WHERE person_id=1; /*person_id is a primary key */

A.
1
Answer
B.
0
C.
No row
D.
None of the mentioned

Answer: Option A

Solution

Answer: Option A
Solution:
This question is about how MySQL deletes data using the DELETE command.
Let's break down the command:
DELETE person: This tells MySQL to delete rows from the table named "person."
WHERE person_id=1: This specifies a condition. It tells MySQL to delete only the row(s) where the column "person_id" has the value "1."
Since person_id is a primary key, it means each row in the table has a unique value for "person_id". This ensures that there can only be one row with "person_id=1".
Therefore, the command will delete exactly one row.
So the correct answer is Option A: 1