外键引用多个表错误

时间:2017-11-08 12:32:29

标签: mysql

我是SQL新手并尝试为影院预订系统创建数据库。但是创建下表会出错。

CREATE TABLE Booking (
    Email VARCHAR(255) NOT NULL,
    PerfDate DATE,
    PerfTime TIME,
    RowNumber CHAR(3),
    FOREIGN KEY (PerfDate, PerfTime) REFERENCES Performance (PerfDate, PerfTime),
    FOREIGN KEY RowNumber REFERENCES Seat (RowNumber),
    );

INSERT INTO Booking VALUES ('ZP@email.com',DATE '2017-11-01',TIME '19:00:00','Z18');
INSERT INTO Booking VALUES ('ZP@email.com',DATE '2017-11-01',TIME '19:00:00','Z19');
INSERT INTO Booking VALUES ('Jane.Dot@live.com',DATE '2017-11-01',TIME '19:00:00','Z16');
INSERT INTO Booking VALUES ('Jane.Dot@live.com',DATE '2017-11-05',TIME '13:00:00','U20');
INSERT INTO Booking VALUES ('Jane.Dot@live.com',DATE '2017-11-05',TIME '13:00:00','U19');
INSERT INTO Booking VALUES ('Mike.Stand@email.com',DATE '2017-11-05',TIME '13:00:00','X13');
INSERT INTO Booking VALUES ('Mike.Stand@email.com',DATE '2017-11-05',TIME '13:00:00','X14');
INSERT INTO Booking VALUES ('qvf3@live.com',DATE '2017-11-05',TIME '13:00:00','Z19');


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REFERENCES Seat (RowNumber),
)' at line 7

我是否错误地设置了FK?

1 个答案:

答案 0 :(得分:1)

请删除字符FOREIGN KEY RowNumber REFERENCES Seat(RowNumber)中的[逗号],