大家好我無法找到在此表中創建位錯誤,似乎真的直截了當地是,這裏就是它給我:MySQL錯誤#1064
錯誤1064第3行:您有一個您的SQL語法錯誤;檢查對應於你的MySQL服務器版本的權利 語法使用近「的外鍵(courses_courseDepartmentAbbv))」在 線 手冊8
DROP TABLE IF EXISTS courses;
CREATE TABLE courses(
courses_courseNumber INT NOT NULL AUTO_INCREMENT,
courses_courseTitle VARCHAR(25) NOT NULL,
courses_courseTeacher VARCHAR(30) NOT NULL,
courses_courseCostOfBooks DECIMAL(5,2) NOT NULL,
courses_courseDepartmentAbbv CHAR(4) NOT NULL,
PRIMARY KEY (courses_courseNumber),
FOREIGN KEY (courses_courseTeacher),
FOREIGN KEY (courses_courseDepartmentAbbv)
);
DROP TABLE IF EXISTS departments;
CREATE TABLE departments(
departments_departmentAbbv CHAR(4) NOT NULL,
departments_departmentFullName VARCHAR(15) NOT NULL,
PRIMARY KEY (departments_departmentAbbv),
FOREIGN KEY (departments_departmentAbbv) REFERENCES (courses_courseDepartmentAbbv)
);
DROP TABLE IF EXISTS teachers;
CREATE TABLE teachers(
teachers_teacherName VARCHAR(20) NOT NULL,
teachers_teacherHomeroom SMALLINT(3) NOT NULL,
teachers_teacherHomeroomGrade SMALLINT(1) NOT NULL,
teachers_teacherFullTime BOOL NOT NULL,
PRIMARY KEY (teachers_teacherName),
FOREIGN KEY (teachers_teacherName) REFERENCES (courses_courseTeacher)
);
試過了,仍然給我同樣的錯誤,雖然 – user1086348 2012-03-24 02:11:36
@ user1086348我更新我的答案的代碼,應該是用作你的參考資料。 – 2012-03-24 02:23:23
真棒我現在明白了,初學者在這裏,謝謝 – user1086348 2012-03-24 02:26:32