'Unfindable SQLite Syntax Error

I'm trying out statements for creating a database, and after 10 entities without any issues I ran into this error

Error: Near line 83: near "Transaction": syntax error

The first line is line 83 with it's context of creating a table

CREATE TABLE Transaction (
TransactionID INTEGER,
AccountID INTEGER REFERENCES User (AccountID),
ItemID INTEGER REFERENCES Item (ItemID),
Method STRING,
Price INTEGER,
TransactionDate DATE,
PRIMARY KEY (TransactionID)
);

Now I can't seem to find the issue, and suggestion's of something with ASCII using the wrong space couldn't be solved by writing the same thing again manually.

I haven't even gotten around to checking the integrity of my foreign keys, and it's not working. Hopefully somebody could provide some insight on what I'm missing.



Solution 1:[1]

Transaction is one of the reserved names in SQLite. For a full list see here.

Ways to solve this issue are:

  • Change the Table name to a word that isn't reserved.

or

  • Quote the reserved name by using one of these 4 listed quote marks
    • 'keyword'
    • "keyword"
    • [keyword]
    • `keyword`

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MadCowDisease