我有一个包含错误的查询。他们在哪?
I have a query which contains mistakes. where are they?
我想在 SQlite 中创建一个 table 但不能:
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)
这里还有一些额外的 table,但它们都很好。我对他们没有问题:
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)
内联外键不带FOREIGN KEY
关键字。
考虑:
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
)
我想在 SQlite 中创建一个 table 但不能:
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)
这里还有一些额外的 table,但它们都很好。我对他们没有问题:
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)
内联外键不带FOREIGN KEY
关键字。
考虑:
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
)