Twinkie
Banned
- Messages
- 1,389
- Reaction score
- 12
- Points
- 0
Why does this query fail?
I know that the 'correct' form is with the constraints defined separately,
but why then can you define primary keys in the column definition? I prefer the SQL / Oracle / Microsoft SQL syntax, and hope to be able to use it with little changes to MySQL.
Code:
CREATE TABLE Order_Items (
Order_ID CHAR(72) NOT NULL FOREIGN KEY REFERENCES Orders(ID),
Product_ID INT(10) UNSIGNED NOT NULL FOREIGN KEY REFERENCES Items(ID),
Quantity INT(10) UNSIGNED NOT NULL,
Notes VARCHAR(255)
);
Code:
CREATE TABLE Order_Items (
Order_ID CHAR(72) NOT NULL,
Product_ID INT(10) UNSIGNED NOT NULL,
Quantity INT(10) UNSIGNED NOT NULL,
Notes VARCHAR(255),
FOREIGN KEY (Order_ID) REFERENCES Orders(ID),
FOREIGN KEY (Product_ID) REFERENCES Items(ID)
);