Consider the following two commands C1 and C2 on the relation R from an SQL…

2016

Consider the following two commands C1 and C2 on the relation R from an SQL database :

C1 : drop table R;

C2 : delete from R;

Which of the following statements is TRUE ?

I. Both C1 and C2 delete the schema for R.

II. C2 retains relation R, but deletes all tuples in R.

III. C1 deletes not only all tuples of R, but also the schema for R.

  1. A.

    I only

  2. B.

    I and II only

  3. C.

    II and III only

  4. D.

    I, II and III

Attempted by 839 students.

Show answer & explanation

Correct answer: C

Answer: Statements II and III are true; Statement I is false.

  • drop table R: Removes the entire table definition (the schema) and all its rows. After this command the relation R no longer exists.

  • delete from R: Deletes all tuples (rows) from the relation but keeps the table and its schema. The empty table can still be queried or have rows inserted.

Therefore:

  1. Statement II is correct because delete from R retains the relation but removes all tuples.

  2. Statement III is correct because drop table R removes both the tuples and the schema.

  3. Statement I is incorrect because only drop table R deletes the schema; delete from R does not.

Explore the full course: Mppsc Assistant Professor