Oracle FOREIGN KEY Constraint
In Oracle, FOREIGN KEY constraint is used to link-up two or more tables. The table in which the foreign key is defined is called the "child table" and it (often) refers to the primary key in the parent table.
Oracle FOREIGN KEY Constraint example
The following Oracle, creates a FOREIGN KEY constraint on the "bankId" column when the "tblbankdemataccountcharges" table is created:
The "pk" column in the "tblbankheadquartersandaddress" table is the PRIMARY KEY in the "tblbankheadquartersandaddress" table.
The "bankId" column in the "tblbankdemataccountcharges" table is a FOREIGN KEY in the "tblbankdemataccountcharges" table.
Oracle FOREIGN KEY Constraint example on ALTER table
The following Oracle, creates a FOREIGN KEY constraint on the "custId" columns when the "tblbankdemataccountcharges" table already exists:
Oracle DROP a FOREIGN KEY Constraint example
The following Oracle, dropping FOREIGN KEY constraint "FK_BankID" from "tblbankdemataccountcharges" table: