我需要一些帮助,我有这样的疑问:
CREATE TABLE IF NOT EXISTS staff_ratio
(id INTEGER PRIMARY KEY AUTOINCREMENT, type INTEGER CHECK ( type IN (0, 1) ) NOT NULL DEFAULT 0,
shift INTEGER CHECK ( shift IN (0, 2, 1)) NOT NULL DEFAULT 0,
personal_count INTEGER, clients INTEGER, ratio REAL, date INTEGER NOT NULL, restaurant_id INTEGER NOT NULL, FOREIGN KEY(restaurant_id) REFERENCES restaurants(id) ON DELETE CASCADE,
hotel_staff_ratio_id INTEGER NOT NULL, FOREIGN KEY(hotel_staff_ratio_id) REFERENCES hotel_staff_ratio(id) ON DELETE CASCADE)
错误:
android.database.sqlite.SQLiteException: near "hotel_staff_ratio_id": syntax error (code 1 SQLITE_ERROR[1])
1条答案
按热度按时间lf5gs5x21#
您混淆了列规范和表约束。
列规范(如
hotel_staff_ratio_id INTEGER NOT NULL
)排在第一位,表约束(如FOREIGN KEY(restaurant_id) REFERENCES restaurants(id) ON DELETE CASCADE
)排在最后。将
hotel_staff_ratio_id INTEGER NOT NULL
移动到第一个FOREIGN KEY
表格约束之前。