SQLite外键错误

时间:2018-02-01 15:24:14

标签: java sqlite jdbc

我刚开始学习JDBC,这里发生了一个问题。我有桌子医生和病人。它们已成功创建,其中包含自己的ID,但我无法创建以下表:

String sqlVisit = "CREATE TABLE IF NOT EXISTS Visit (" +
       "id INTEGER PRIMARY KEY NOT NULL," +
       "doctor_id INTEGER NOT NULL," +
       "FOREIGN KEY (doctor_id) REFERENCES Doctor (id)," +
       "patient_id INTEGER NOT NULL," +
       "FOREIGN KEY (patient_id) REFERENCES Patient (id),"+
       "cost DOUBLE NOT NULL," +
       "date DATE" +
       ")";

错误行:

org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (near "patient_id": syntax error)

我不知道我做错了什么,试图找到解决方案,但没有成功。

0 个答案:

没有答案