I have successfully created a table using:
CREATE TABLE "countermeasure"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"name" VARCHAR,
"description" TEXT check(typeof("description") = 'text'),
"probability" DOUBLE,
"cost" DOUBLE
)
and now I need to add a foreign key to it using:
ALTER TABLE "countermeasure"
(ADD "attack_id" INTEGER,
FOREIGN KEY ( "attack_id") REFERENCES attack(id)
)
but it complains with the error:
SQLiteManager: Likely SQL syntax error: ALTER TABLE "countermeasure" (
ADD "attack_id" INTEGER ,
FOREIGN KEY ( "attack_id") REFERENCES attack(id) ) [ near "(": syntax error ]
Exception Name: NS_ERROR_FAILURE
I am sure I've created the attack table well.
REFERENCES attack(id)so just a suggestion. - Anandalter tablestatement when you're adding a column. - Mike Sherrill 'Cat Recall'