Click here to Skip to main content
15,891,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In MSSQL and MySQL when declaring foreign keys we used this format

CONSTRAINT fk_emp FOREIGN KEY (P_Id)
REFERENCES Persons(P_Id)

but in oracle don't specify the column name of the table that we need to add a reference to.

it was done like this

CONSTRAINT fk_emp FOREIGN KEY (P_Id)
REFERENCES Persons

in this case how does the db know which column needs to be referenced with the column in persons table?
Posted

1 solution

According to the documentation - http://docs.oracle.com/cd/B28359_01/server.111/b28286/clauses002.htm[^], " Because the referenced key is the primary key of the parent table, the referenced key column names are optional.".
Scott
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900