I want to create a table in SQlite but can't:
CREATE TABLE IF NOT EXISTS[Goods]
(GoodId INTEGER PRIMARY KEY AUTOINCREMENT,
GoodName varchar(100) not null,
CategoryId INTEGER FOREIGN KEY (CategoryId) REFERENCES Category (CategoryId),
ProducerId INTEGER FOREIGN KEY (ProducerId) REFERENCES Producer (ProducerId),
Price REAL not null,
GoodCount REAL not null)
here are additional tables but they are all right. I don't have problems with them:
CREATE TABLE IF NOT EXISTS[Category] (CategoryId INTEGER PRIMARY KEY
AUTOINCREMENT, CategoryName varchar(100) not null)
CREATE TABLE IF NOT EXISTS[Producer] (ProducerId INTEGER PRIMARY KEY
AUTOINCREMENT, ProducerName varchar(100) not null)
Inline foreign keys do not take the FOREIGN KEY
keyword.
Consider:
CREATE TABLE IF NOT EXISTS[Goods] (
GoodId INTEGER PRIMARY KEY AUTOINCREMENT,
GoodName varchar(100) not null,
CategoryId INTEGER REFERENCES Category (CategoryId),
ProducerId INTEGER REFERENCES Producer (ProducerId),
Price REAL not null,
GoodCount REAL not null
)