Reputation: 619
Hello everyone i got this error while trying to create a table in my database, have checked my query carefully but could not understand where the problem is:
sqlite> CREATE TABLE Subreddit (subreddit VARCHAR(15) PRIMARY KEY,name_name VARCHAR(15), FOREIGN KEY(name_name) REFERENCES Name(name), subreddit_id VARCHAR(15) );
Error: near "subreddit_id": syntax error
Upvotes: 0
Views: 23
Reputation: 26569
Table constraints must come after all column definitions. You are declaring a column subreddit_id
after you specify a foreign key constraint, which is invalid syntax.
Simply swap the definition of subreddit_id
and the FOREIGN KEY
definition.
Upvotes: 1