Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: Foreign Key Constraints Jump to:  
Category: >> Oracle PL/SQL >> Foreign Key Constraints Bookmark and Share

<< lastnext >>

Snippet Name: Foreign Key Constraints

Description: The sole purpose of a foreign key constraint is to define a relationship between two tables.

This foreign key column establishes a direct relationship with a primary key or unique key column (referenced key) usually in another table.

The table containing the foreign key is referred to as the child, and the table containing the referenced key is the parent table.

The foreign key and referenced key can be in the same table (parent and child are the same table); otherwise, the parent and child tables must be in the same database.

Also see:
» Check Constraint - Create
» Unique Constraint
» Primary Key Constraint
» Current_timestamp
» Deferring Constraint Checking
» Add Primary Key Constraint example
» Constraint Checks
» Add constraint example

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 07th, 2009

ALTER TABLE RB_ACCOUNTS DROP CONSTRAINT RACCO_FK1; 
ALTER TABLE RB_ACCOUNTS DROP CONSTRAINT RACCO_FK3; 
ALTER TABLE RB_ACCOUNTS DROP CONSTRAINT RACCO_FK7; 
ALTER TABLE RB_ACCOUNT_CHARGES DROP CONSTRAINT RACH_FK1; 
ALTER TABLE RB_TAPE_FORMAT_BANDS DROP CONSTRAINT RTFB_FK1; 
 
ALTER TABLE RB_ACCOUNTS
     ADD CONSTRAINT racco_fk1 FOREIGN KEY (CUSTOMER_ID) 
     REFERENCES RB_CUSTOMERS (CUSTOMER_ID);
 
ALTER TABLE RB_ACCOUNTS
     ADD CONSTRAINT racco_fk3 FOREIGN KEY (BILLING_CYCLE_ID) 
     REFERENCES RB_BILLING_CYCLES (BILLING_CYCLE_ID);
 
ALTER TABLE RB_ACCOUNTS
     ADD CONSTRAINT racco_fk4 FOREIGN KEY (CSR_PEOPLE_ID) 
     REFERENCES RB_PEOPLE (PEOPLE_ID);
 
ALTER TABLE RB_TAPE_FORMAT_BANDS
     ADD CONSTRAINT rtfb_fk1 FOREIGN KEY (FORMAT_ID)
     REFERENCES RB_TAPE_FORMATS (FORMAT_ID);


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 63 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?