1SELECT c.OWNER, a.TABLE_NAME, a.COLUMN_NAME, a.CONSTRAINT_NAME,
2 c.R_OWNER AS REF_OWNER, cpk.TABLE_NAME AS REF_TABLE,
3 cpk.CONSTRAINT_NAME AS REF_PK
4FROM ALL_CONS_COLUMNS a
5JOIN ALL_CONSTRAINTS c ON a.OWNER = c.OWNER
6 AND a.CONSTRAINT_NAME = c.CONSTRAINT_NAME
7 JOIN ALL_CONSTRAINTS cpk ON c.R_OWNER = cpk.OWNER
8 AND c.R_CONSTRAINT_NAME = cpk.CONSTRAINT_NAME
9WHERE c.CONSTRAINT_TYPE = 'R' AND c.TABLE_NAME= 'table_name';
1CREATE TABLE hr.admin_emp (
2 empno NUMBER(5) PRIMARY KEY,
3 ename VARCHAR2(15) NOT NULL,
4 ssn NUMBER(9) ENCRYPT,
5 job VARCHAR2(10),
6 mgr NUMBER(5),
7 hiredate DATE DEFAULT (sysdate),
8 photo BLOB,
9 sal NUMBER(7,2),
10 hrly_rate NUMBER(7,2) GENERATED ALWAYS AS (sal/2080),
11 comm NUMBER(7,2),
12 deptno NUMBER(3) NOT NULL
13 CONSTRAINT admin_dept_fkey REFERENCES hr.departments
14 (department_id))