CREATE TABLE employee (
empno INTEGER NOT NULL PRIMARY KEY, ename CHAR (30) NOT NULL, deptno INTEGER NOT NULL, mgr_code INTEGER REFERENCES employee (empno) ) ; INSERT INTO employee VALUES (100, 'JOHN', 10, NULL) ; INSERT INTO employee VALUES (500, 'MARY', 30, NULL) ; INSERT INTO employee VALUES (101, 'ANITA', 10, NULL) ; INSERT INTO employee VALUES (501, 'ROBERT', 30, NULL) ; UPDATE employee set mgr_code = 101 where empno = 100 ; UPDATE employee set mgr_code = 501 where empno = 500 ; /* ** Anita is John's manager. ** John's employee row references Anita's employee row. ** Robert is Mary's manager. ** Mary's employee row references Robert's employee row. ** The mgr_code is still NULL in Anita's row and in Robert's row. ** To set the mgr_code in Anita's row and Robert's row: ** 1. Insert rows for Anita's manager and Robert's manager ** 2. Update Anita's row and Robert's row */ |