in Databases recategorized by
868 views
1 vote
1 vote

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

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) NOTNULL,
    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/queries will drop the ‘SALARY’ column from ‘EMPLOYEE’ table?

  1. ALTER TABLE EMPLOYEE DROP SALARY CASCADE
    
  2. ALTER TABLE EMPLOYEE DROP SALARY RESTRICT
    
  3. ALTER EMPLOYEE DROP SALARY
    

Choose the correct answer from the options given below:

  1. $a$ and $b$ only
  2. $a$ and $c$ only
  3. $b$ and $c$ only
  4. $a$ only
in Databases recategorized by
868 views

1 Answer

0 votes
0 votes

Ans is option  A) a and b only 

C is incorrect syntax

Dropping columns

Syntax

ALTER TABLE table-Name    
    DROP [ COLUMN ] column-name [ CASCADE | RESTRICT ]
    
The keyword COLUMN is optional.

The keywords CASCADE and RESTRICT are also optional. If you specify neither CASCADE nor RESTRICT, the default is CASCADE.

If you specify RESTRICT, then the column drop will be rejected if it would cause a dependent schema object to become invalid.

If you specify CASCADE, then the column drop should additionally drop other schema objects which have become invalid.

Here salary field is not present in any other table  so no effect of CASCADE | RESTRICT


https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqlj81859.html

                        

Answer:

Related questions