Machine-translated by Google. Questions are authored in English.
Top

Discussion

Database contains two tables : Employee (id, name, salary, did) and Dept. (did, dname).

Which of the following is an incorrect SQL query ?

  • A.Select name, dname from employee natural join Dept;
  • B.Delete from employee where did in (Select did from Dept);
  • C.Update employee set salary = salary * 1.03 where salary \(\gt\) 100000;
  • D.Insert values into employee (1, 'vijay', 100000, 12);

Answer: D

The incorrect query is Insert values into employee (1, 'vijay', 100000, 12);.

The SQL syntax is INSERT INTO table VALUES (...): the keyword INTO and the table name come before VALUES. The statement as written puts VALUES first and omits INTO, so it is a syntax error. The correct form is Insert into employee values (1, 'vijay', 100000, 12);.

The others are valid. The natural join matches the two tables on their common column did. The delete uses a subquery with IN. The update raises the salary by 3% for rows where salary exceeds 100000.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.