Multiple choice technology databases

With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?

  1. INSERT ('Olsen') INTO Persons (LastName)

  2. INSERT INTO Persons (LastName) VALUES ('Olsen')

  3. INSERT INTO Persons ('Olsen') INTO LastName

  4. INSERT FROM Persons ('Olsen') INTO LastName

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

The standard SQL syntax to insert records into a table is 'INSERT INTO table_name (columns) VALUES (values)'. The other options utilize incorrect keyword structures, wrong order of arguments, or non-existent SQL syntax.

AI explanation

To insert "Olsen" as the "LastName" in the "Persons" table using SQL, you can use the following syntax:

B. INSERT INTO Persons (LastName) VALUES ('Olsen')

Explanation: Option A: INSERT ('Olsen') INTO Persons (LastName) - This is an incorrect syntax. The correct syntax for the INSERT statement requires the keyword "INTO" before the table name, followed by the column names in parentheses, and the keyword "VALUES" before the values to be inserted.

Option B: INSERT INTO Persons (LastName) VALUES ('Olsen') - This is the correct syntax. It specifies the table "Persons" and the column "LastName" where the value 'Olsen' will be inserted.

Option C: INSERT INTO Persons ('Olsen') INTO LastName - This is an incorrect syntax. The correct syntax for the INSERT statement requires the keyword "VALUES" before the values to be inserted.

Option D: INSERT FROM Persons ('Olsen') INTO LastName - This is an incorrect syntax. The correct syntax for the INSERT statement does not include the keyword "FROM" before the table name, and the column name should be specified before the keyword "VALUES".

Therefore, the correct answer is B. INSERT INTO Persons (LastName) VALUES ('Olsen').