lazierthanthou / sqlite-manager

Manage all your sqlite databases using this lightweight extension for firefox, thunderbird, seamonkey, komodo etc.
http://lazierthanthou.github.io/sqlite-manager/
325 stars 133 forks source link

Adding FOREIGN KEY error #84

Open csanyipal opened 7 years ago

csanyipal commented 7 years ago

Hi,

I have a simple database which I attached here as a zip file: Classes.db.zip

I want to add a FOREIGN KEY as follows in the code bellow, by following advice from here: (https://github.com/lazierthanthou/sqlite-manager/wiki/Foreign-Key-support) `ALTER TABLE "main"."students" RENAME TO "oXHFcGcd04oXHFcGcd04_students" CREATE TABLE "main"."students" ("student_id" TEXT NOT NULL ,"first_name" TEXT NOT NULL ,"last_name" TEXT NOT NULL ,"class_name" TEXT, FOREIGN KEY(class_name) REFERENCES classes(class_name), DEFAULT (null) )

INSERT INTO "main"."students" SELECT "student_id","first_name","last_name","class_name" FROM "main"."oXHFcGcd04oXHFcGcd04_students" DROP TABLE "main"."oXHFcGcd04oXHFcGcd04_students"` but get always the following error:

SQLiteManager: CREATE TABLE "main"."students" ("student_id" TEXT NOT NULL ,"first_name" TEXT NOT NULL ,"last_name" TEXT NOT NULL ,"class_name" TEXT, FOREIGN KEY(class_name) REFERENCES classes(class_name), DEFAULT (null) ) [ near "DEFAULT": syntax error ] Exception Name: NS_ERROR_FAILURE Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [mozIStorageConnection.createStatement]

What am I missing here?

Best, Pali