Let use assume 2 schemas scott1 and scott2.
In scott1 we have emp table and in scott2 we have dept table. Now take the requirement to establish foreign key relation ship between scott1.emp and scott2.dept;
SQL> GRANT REFERENCES ON SCOTT2.DEPT TO SCOTT1
SQL> CONN SCOTT1/PASSWORD
SQL> ALTER TABLE EMP ADD CONSTRAINT FK_EMP_DEPTID FOREIGN KEY (SCOTT_DEPT_ID) REFERENCES SCOTT2.DEPT (ID);
In scott1 we have emp table and in scott2 we have dept table. Now take the requirement to establish foreign key relation ship between scott1.emp and scott2.dept;
SQL> GRANT REFERENCES ON SCOTT2.DEPT TO SCOTT1
SQL> CONN SCOTT1/PASSWORD
SQL> ALTER TABLE EMP ADD CONSTRAINT FK_EMP_DEPTID FOREIGN KEY (SCOTT_DEPT_ID) REFERENCES SCOTT2.DEPT (ID);
No comments:
Post a Comment