Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Foreign Key

Author  Topic 

hli1022
Starting Member

1 Post

Posted - 2011-01-10 : 23:36:35
im currently using Oracle SQL and im trying to figure out how to code a foreign key, i tried the following, but i keep getting an error message that says "Missing Right Parenthesis." please advice, thank you.

CREATE TABLE Orders
(
O_Id int NOT NULL PRIMARY KEY,
OrderNo int NOT NULL,
P_Id int FOREIGN KEY REFERENCES Persons(P_Id)
)

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2011-01-11 : 00:08:43
Try:
CREATE TABLE Orders
(
O_Id int NOT NULL PRIMARY KEY,
OrderNo int NOT NULL,
P_Id int,
Constraint Order_PID FOREIGN KEY (P_ID) REFERENCES Persons(P_Id)
)
Go to Top of Page
   

- Advertisement -