Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



Consider the following table structures related to a university for the below questions. EMPLOYEE
NAME VARCHAR(30) NOT NULL
EID VARCHAR(10) NOT NULL
DEPTNO INT(5) NOT NULL
HODEID VARCHAR(10)
SALARY INT(10)
PRIMARY KEY (EID), FOREIGN KEY (HODEID) REFERENCES EMPLOYEE (EID), FOREIGN KEY (DEPTNO) REFERENCES DEPARTMENT (DID); DEPARTMENT
DID INT(5) NOT NULL
DNAME VARCHAR(30) NOT NULL
HODID VARCHAR(10) NOT NULL
HODNAME VARCHAR(30)
PRIMARY KEY (DID), UNIQUE (DNAME), FOREIGN KEY (HODID) REFERENCES EMPLOYEE (EID); PROJECT WORK
EMPID VARCHAR(10) NOT NULL
PROJNO INT(5) NOT NULL
PROJECTLOC VARCHAR(30) NOT NULL
PRIMARY KEY (EMPID, PROJNO), FOREIGN KEY (EMPID) REFERENCES EMPLOYEE (EID);

In reference to the above given table structures, which of the following query or 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::





Solution

To drop a column from a table, correct SQL syntax is:

ALTER TABLE table_name DROP column_name;

In Statement (A):

ALTER TABLE EMPLOYEE DROP SALARY CASCADE;

This query is valid because it uses ALTER TABLE and drops the SALARY column.

CASCADE means if there are dependent objects, they may also be removed.

So, Statement (A) is correct.

In Statement (B):

ALTER TABLE EMPLOYEE DROP SALARY RESTRICT;

This query is also valid because it uses ALTER TABLE and drops the SALARY column.

RESTRICT means the column will be dropped only if there is no dependent object.

Here, SALARY is not used as a primary key or foreign key.

So, Statement (B) is also correct.

In Statement (C):

ALTER EMPLOYEE DROP SALARY;

This query is incorrect because the keyword TABLE is missing.

Correct syntax should have ALTER TABLE, not only ALTER.

So, Statement (C) is incorrect.

Therefore, correct queries are (A) and (B) only.


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...