Database-Management-System
August 29, 2024
Database-Management-System
August 29, 2024
Database-Management-System
August 29, 2024
Database-Management-System
August 29, 2024

Database-Management-System

Question 285
Comprehension:

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
(A) and (B) only
B
(A) and (C) only
C
(B) and (C) only
D
(A) only
Question 285 Explanation: 
Restrict and Cascade

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.

Correct Answer: A
Question 285 Explanation: 
Restrict and Cascade

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.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!