本文介绍了CREATE TABLE 中 FOREIGN KEY 的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在调试器上得到以下输出.我不确定缺少什么语法.
I am getting following output on debugger. I am not sure what syntax is missing.
SQL 代码为:
CREATE TABLE weeks(Week_Id INTEGER PRIMARY KEY,
Day TEXT,
Start_Time Text,
End_Time Text,
Break_Time Text );
CREATE TABLE projects(Project_Id INTEGER PRIMARY KEY,
Name TEXT,
Description Text,
Client_Name Text,
Location Text );
CREATE TABLE timesheets(Timesheet_Id INTEGER PRIMARY KEY,
Project_Id INTEGER,
FOREIGN KEY (Project_Id) REFERENCES projects (Project_Id),
Week_Id INTEGER,
FOREIGN KEY (Week_Id) REFERENCES weeks (Week_Id));
错误归结为:
12-09 12:34:20.782: E/SQLiteLog(6490): (1) near "Week_Id": syntax error
推荐答案
尝试将 FOREIGN KEY
列表移动到创建变量之后.
Try moving your FOREIGN KEY
lists to after your variables are created.
CREATE TABLE timesheets(Timesheet_Id INTEGER PRIMARY KEY,
Project_Id INTEGER,
Week_Id INTEGER,
FOREIGN KEY (Project_Id) REFERENCES projects (Project_Id),
FOREIGN KEY (Week_Id) REFERENCES weeks (Week_Id));
这篇关于CREATE TABLE 中 FOREIGN KEY 的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!