Skip to main contentSkip to solution

Consider an employee table having two columns namely 'LastName' and 'FirstName'. Identify the Correct INSERT queries from the following:

A. INSERT INTO employee ("aaa","bbb");

B. INSERT INTO employee VALUE ("aaa","bbb");

C. INSERT INTO employee VALUES ("aaa","bbb");

D. INSERT INTO employee (LastName, FirstName) VALUES ("aaa","bbb");

Solution

✅ Correct Option: 3

Standard SQL has two valid forms of INSERT. The first is INSERT INTO table VALUES (...)\text{INSERT INTO table VALUES (...)}, which supplies a value for every column in table order, as in C. The second is INSERT INTO table (col1, col2) VALUES (...)\text{INSERT INTO table (col1, col2) VALUES (...)}, which names the columns explicitly, as in D.


A: it has no VALUES keyword, so the syntax is invalid.

B: the keyword is VALUES, not VALUE, in standard SQL (MySQL happens to accept VALUE as a synonym, but it is not standard).

When a column list is not given, the values must follow the table's column order. Here that means LastName first, then FirstName.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question