Database-Management-System
August 29, 2024Database-Management-System
August 29, 2024Database-Management-System
Question 285
|
Consider the following table structures related to a university for Q96 to Q100:-
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 (DANAME),
FOREIGN KEY (HODID) REFERENCES EMPLOYEE (EID);
PROJECT WORK:
EMPID VARCHAR (30) NOT NULL,
PROJNO INT (5) NOT NULL,
PROJECTLOC VARCHAR (30) NOT NULL,
PRIMARY KEY (EMPID, PROJNO),
FOREIGN KEY (EMPID) REFERENCES EMPLOYEE (EID),
SubQuestion No: 100
Q100: 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 TABLE EMPLOYEE DROP SALARY;
Choose the correct answer from the options given below:
(A) and (B) only
|
|
(A) and (C) only
|
|
(B) and (C) only
|
|
(A) only
|
When a constraint or a column is dropped, specify either the RESTRICT or CASCADE option:
RESTRICT
Does not drop the constraint or column if one or more objects exist that depend on it. For example:
•A view with reference to the column in the base table
•A check constraint on the column being dropped
•A secondary index defined with this column
CASCADE
Deletes all objects that depend on the dropped constraint or column.
For example, if a unique constraint upon which a referential constraint is dependent is dropped, the dependent constraints are dropped. If a column is dropped, all integrity constraints, grants, views, and indexes that depend on the column are dropped.
The user is not provided with information describing the dependent objects that are dropped.
(A): mysql> alter table employee drop salary cascade;
Query OK, 0 rows affected
(B): mysql> alter table employee drop salary restrict;
Query OK, 0 rows affected
(C): Syntactical error. The ‘table’ keyword should be used along with alter command.
When a constraint or a column is dropped, specify either the RESTRICT or CASCADE option:
RESTRICT
Does not drop the constraint or column if one or more objects exist that depend on it. For example:
•A view with reference to the column in the base table
•A check constraint on the column being dropped
•A secondary index defined with this column
CASCADE
Deletes all objects that depend on the dropped constraint or column.
For example, if a unique constraint upon which a referential constraint is dependent is dropped, the dependent constraints are dropped. If a column is dropped, all integrity constraints, grants, views, and indexes that depend on the column are dropped.
The user is not provided with information describing the dependent objects that are dropped.
(A): mysql> alter table employee drop salary cascade;
Query OK, 0 rows affected
(B): mysql> alter table employee drop salary restrict;
Query OK, 0 rows affected
(C): Syntactical error. The ‘table’ keyword should be used along with alter command.