mysql> CREATE TABLE Orders
-> (
-> O_Id int NOT NULL,
-> OrderNo int NOT NULL,
-> P_Id int,
-> PRIMARY KEY (O_Id),
-> FOREIGN KEY (P_Id)
-> );
错误1064(42000):您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以获得正确的语法,以便在附近使用')'在第8行
在更改命令后,它给了我这个
mysql> CREATE TABLE Orders
-> (
-> O_Id int NOT NULL,
-> OrderNo int NOT NULL,
-> P_Id int,
-> PRIMARY KEY (O_Id),
-> CONSTRAINT fk_PerOrders FOREIGN KEY (P_Id)
-> REFERENCES Persons(P_Id)
-> );
ERROR 1215(HY000):无法添加外键约束