0

我正在尝试使用 MySQL 创建下表:

CREATE TABLE registrations (
    eventNumber CHAR(3) UNIQUE NOT NULL
        CHECK (EXISTS (SELECT eventNumber FROM events)),
    employeeNumber CHAR(5) UNIQUE NOT NULL 
        CHECK (EXISTS (SELECT employeeNumber FROM employees)),

    PRIMARY KEY(eventNumber , employeeNumber ),

    FOREIGN KEY (eventNumber) REFERENCES eventNumber (employees)
        ON UPDATE RESTRICT 
        ON DELETE RESTRICT,
    FOREIGN KEY (employeeNumber ) REFERENCES employeeNumber(employees)
        ON UPDATE RESTRICT 
        ON DELETE RESTRICT  
) ENGINE=InnoDB;

但是,当我运行命令时出现无法创建表错误 (1005)。这里可能出了什么问题?

4

1 回答 1

1

作为参考,我把 REFERENCES 语句弄错了。

它实际上应该是:

REFERENCES <table name>(<attribute name>)
于 2012-12-05T16:29:41.793 回答