Consider the following table structures related to a university for the below…

2020

 Consider the following table structures related to a university for the below question

In reference to the above given table structures, which of the following query/queries will drop the ‘SALARY’ column from ‘EMPLOYEE’ table?

(A)    ALTER TABLE EMPLOYEE DROP SALARY CASCADE

(B)    ALTER TABLE EMPLOYEE DROP SALARY RESTRICT

(C)    ALTER EMPLOYEE DROP SALARY

Choose the correct answer from the options given below:

  1. A.

    (A) and (B) Only

  2. B.

    (A) and (C) Only

  3. C.

    (B) and (C) Only

  4. D.

    (A) Only

Attempted by 670 students.

Show answer & explanation

Correct answer: A

Answer: Both statements 'ALTER TABLE EMPLOYEE DROP SALARY CASCADE' and 'ALTER TABLE EMPLOYEE DROP SALARY RESTRICT' will drop the SALARY column; the statement 'ALTER EMPLOYEE DROP SALARY' is invalid because it omits the TABLE keyword.

  • Valid forms and behavior: The standard pattern to remove a column is ALTER TABLE table_name DROP COLUMN column_name [CASCADE|RESTRICT]. Many SQL dialects also accept dropping without explicitly writing COLUMN (as shown in the two valid statements).

  • CASCADE vs RESTRICT: CASCADE removes the column and any dependent constraints or objects; RESTRICT prevents the drop when there are dependent objects, producing an error instead.

  • Why the third statement is invalid: 'ALTER EMPLOYEE DROP SALARY' is a syntax error because it does not include the TABLE keyword (ALTER TABLE ...).

  • Recommended explicit form (portable): ALTER TABLE EMPLOYEE DROP COLUMN SALARY CASCADE or ALTER TABLE EMPLOYEE DROP COLUMN SALARY RESTRICT.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor