Sample Exam Questions

From the objective of OSS-DB Exam Silver
- Development/SQL - SQL command
(UPDATE statement)

Sample Question

3.04

Regardless of the table definition, choose two
statements that always result in an error.

  1. DELETE FROM t1. Table1 t 2 WHERE a = b;
  2. DELETE table1 WHERE column 1 = 100;
  3. DELETE FROM table1 t1, table2 t2 WHERE t1. A = t 2. B;
  4. DELETE FROM table1;
  5. DELETE FROM table1 WHERE a IN (SELECT x FROM table2);

※This sample exam is different from those that appear in the actual OSS-DB Exam.
2018/04/07

Answer and Explanation

The basic syntax of the DELETE statement is below.

DELETE FROM table name ((AS) table alias) WHERE conditional expression Since FROM is mandatory, B becomes an error.

Unlike SELECT statements, you can not put more than one table in a comma-separated list in the FROM clause. Therefore C also causes an error.

T1.table1 t2 in the FROM clause of A means that the table named table1 in the schema t1 is to be deleted and t1.table1 is referred to by another name t2. a = b in the WHERE clause means that if the value of column a is equal to the value of column b, it is deleted. Therefore, if there exists a schema, table, and column of such a name and if a and b are comparable then it is not an error.

D has no WHERE clause, but in this case all rows of table1 are deleted. By executing from psql, you can not ROLLBACK by default, so be very careful.

E is a SELECT statement in the WHERE clause, but if the value of column a of table1 is included in the set of values returned by the SELECT statement in parentheses, those rows from table1 is deleted. Therefore, if columns a and x exist in table1 and table2, respectively, and if a and x can be compared, no error occurs.

It is a matter of choosing what is wrong, so the correct answer are B and C.