0
不工作我想引用兩個單獨的表創建第三個表,但是SQL說,有在FOREIGN KEY
近洋引用外鍵在SQL
import sqlite3 as db
connection = db.connect("doctor_who_database")
cursor = connection.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS doctor_who_database(
item_id TEXT PRIMARY KEY,
item TEXT)""")
cursor.execute("""CREATE TABLE IF NOT EXISTS doctor_who_database2(
person_id TEXT PRIMARY KEY,
season TEXT,
person TEXT)""")
cursor.execute("""CREATE TABLE IF NOT EXISTS doctor_who_database3(
id TEXT PRIMARY KEY,
item TEXT,
season TEXT,
person TEXT)""")
cursor.execute("""FOREIGN KEY(item_id) REFERENCES doctor_who_database(item_id)""")
我看不出有任何語法錯誤。 ..也許你忘了在你的問題中包含回溯..? – thebjorn