Foreign Key
A foreign key relationship is one in which a column from one table is referenced in another.
SQL> CREATE TABLE departments
2 (department_id number(10) not null,
3 department_name varchar2(50) not null,
4 CONSTRAINT departments_pk PRIMARY KEY (department_id)
5 );
Table created.
SQL>
SQL>
SQL> CREATE TABLE employees
2 ( employee_id number(10) not null,
3 last_name varchar2(50) not null,
4 job_id varchar2(30),
5 department_id number(10),
6 salary number(6),
7 manager_id number(6),
8 CONSTRAINT employees_pk PRIMARY KEY (employee_id),
9 CONSTRAINT fk_departments FOREIGN KEY (department_id)
10 REFERENCES departments(department_id)
11 );
Table created.
SQL>