Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle FOREIGN KEY Constraint      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: FOREIGN KEY

Definition:
In its simplest form, a foreign key is a referential constraint between two tables. A foreign key constraint validates the values of an INSERT or UPDATE against the values in another column, either in a different table or another column in the same table. Generally, though, a foreign key is a field (or fields) that points to the primary key of another table.

A foreign key can also be described as a column in a table that does NOT uniquely identify rows in that table, but is used as a link to matching columns in other tables to indicate a relationship.

A foreign key always defines a parent/child relationship. The "parent" is the column that is referenced in the foreign key and the "child" is the column or columns that contain the foreign key constraint.

Example Syntax:
In this example, the Customer_SID column in the ORDERS table is a foreign key pointing to the SID column in the CUSTOMER table:

CREATE TABLE ORDERS
(Order_ID integer primary key,
Order_Date date,
Customer_SID integer references CUSTOMER(SID),
Amount double);
Amount double);


You may also want to see additional information in the entry on the CONSTRAINT clause.


Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 141 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?