How do I create a table MANAGER (EMP-NO, MANAGER) where
MANAGER is a foreign key which references to EMP-NO in the
same table? Give the exact DDL.

Answers were Sorted based on User's Feedback



How do I create a table MANAGER (EMP-NO, MANAGER) where MANAGER is a foreign key which references ..

Answer / shankar v

Above one is true but a small correction is needed as below:

CREATE TABLE TB_MANAGER
(EMP-N0 CHAR(6) PRIMARY KEY NOT NULL,
MANAGER CHAR(6) NOT NULL)
IN TABLESPACE;

ALTER TABLE MANAGER
FOREIGN KEY (MANAGER) REFERENCES TB_MANAGER(EMP_NO)
ON DELETE CASCADE;

Is This Answer Correct ?    3 Yes 0 No

How do I create a table MANAGER (EMP-NO, MANAGER) where MANAGER is a foreign key which references ..

Answer / s

CREATE TABLE QUALIFIER.TABLE
(EMP-N0 CHAR(6) NOT NULL,
MANAGER CHAR(6) NOT NULL)
IN TABLESPACE;

ALTER TABLE QUALIFIER.TABLE
FOREIGN KEY FKM (MANAGER) REFERENCES QUALIFIER.TABLE
ON DELETE CASCADE;

Is This Answer Correct ?    1 Yes 1 No

How do I create a table MANAGER (EMP-NO, MANAGER) where MANAGER is a foreign key which references ..

Answer / sahil garg

CREATE TABLE TB_MANAGER
(EMPNO CHAR(6) PRIMARY KEY ,
MANAGER CHAR(6) );


ALTER TABLE TB_MANAGER
ADD CONSTRAINT TB_FK FOREIGN KEY (MANAGER) REFERENCES
TB_MANAGER(EMPNO);

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More DB2 Interview Questions

what is the sqlcode -501

5 Answers   IBM, Polaris, Zeus,


How is the SUBSTR keyword used in sql?

1 Answers  


What is reorg?

0 Answers  


List some fields from sqlca?

0 Answers  


What is bind in db2?

0 Answers  


Why do we need to create an alias if we can directly use the table name? What are the benefits of referring a table name by its alias? Also, when should we go for alias and when for synonyms?

1 Answers  


List out the three types of page locks that can be held.

0 Answers  


What is Call attach facility? How does it work?

1 Answers   Syntel,


What is null in db2?

0 Answers  


How we create a tables in db2,what is the process/syntax to create a table with example plz?

2 Answers  


If a table has a column "dept" (declared to have nulls) and there are 10 rows in the table of which 3 have a null value in the dept column, what will select count(*) and select count(distinct dept) return?

6 Answers  


DB2: A calls B once sucessfull and second time when it calls says curson is open why is it so?

1 Answers   IBM,


Categories