Multiple choice technology databases

With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?

  1. DELETE FROM Persons WHERE FirstName = 'Peter' ;

  2. DELETE FirstName='Peter' FROM Persons;

  3. DELETE ROW FirstName='Peter' FROM Persons ;

  4. TRUNCATE FROM Persons WHERE FirstName='Peter'

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To solve this question, the user needs to know the basic syntax for deleting records in SQL, including the correct use of the DELETE command and WHERE clause.

Now, let's go through each option and explain why it is right or wrong:

A. DELETE FROM Persons WHERE FirstName = 'Peter' ; This option is correct. The DELETE command is used to delete records from a table in SQL. The WHERE clause is used to specify the condition that must be met for a record to be deleted. In this case, we want to delete all records where the FirstName is Peter, so we use the WHERE FirstName = 'Peter' condition.

B. DELETE FirstName='Peter' FROM Persons; This option is incorrect. The correct syntax for the DELETE command is DELETE FROM table_name, followed by the WHERE clause. In this option, the syntax is incorrect because the table name is missing, and the condition is in the wrong place.

C. DELETE ROW FirstName='Peter' FROM Persons ; This option is incorrect. The correct syntax for the DELETE command is DELETE FROM table_name, followed by the WHERE clause. In this option, the syntax is incorrect because the ROW keyword is not used in the correct way.

D. TRUNCATE FROM Persons WHERE FirstName='Peter' This option is incorrect. The TRUNCATE command is used to delete all records from a table, not specific records that meet a certain condition. Also, the syntax is incorrect because the WHERE clause is used in the wrong place.

The Answer is: A. DELETE FROM Persons WHERE FirstName = 'Peter' ;

AI explanation

Standard SQL syntax for removing rows matching a condition is DELETE FROM WHERE ;. So 'DELETE FROM Persons WHERE FirstName = \'Peter\';' is correct. The other options are invalid syntax: DELETE does not take a direct column=value clause without FROM/WHERE structured properly ('DELETE FirstName=... FROM Persons' is not valid SQL), there is no 'DELETE ROW' statement, and TRUNCATE never accepts a WHERE clause -- TRUNCATE removes all rows in a table unconditionally and cannot be filtered.