我正在嘗試爲我的android應用程序實現數據庫升級。我嘗試使用以下代碼:升級SQLite數據庫時出錯
// Create a table that is equivalent to the existing one but with one column as TEXT instead of INTEGER
db.execSQL("CREATE VIRTUAL TABLE distributors_new USING FTS3 (fname TEXT, lname TEXT, phoneNumber TEXT, email TEXT, notes TEXT, parentid INTEGER, customid TEXT FOREIGN KEY (parentid) REFERENCES distributors(rowid) ON DELETE CASCADE ON UPDATE CASCADE);");
//Insert all data from the old table to the new one.
db.execSQL("INSERT INTO distributors_new SELECT * FROM distributors;");
// Drop the old table
db.execSQL("DROP TABLE distributors;");
// Rename the new table
db.execSQL("ALTER TABLE distributors_new RENAME TO distributors;");
但是,我在執行onUpgrade方法後出現錯誤。
02-12 16:31:16.324: ERROR/Database(1456): Failure 1 (SQL logic error or missing database) on 0x26b338 when executing 'COMMIT;'
02-12 16:31:16.334: ERROR/SQLiteOpenHelper(1456): Couldn't open mlmDB for writing (will try read-only):
02-12 16:31:16.334: ERROR/SQLiteOpenHelper(1456): android.database.sqlite.SQLiteException: SQL logic error or missing database: COMMIT;
02-12 16:31:16.334: ERROR/SQLiteOpenHelper(1456)
我在做什麼錯?
沒有服務器。它是一個android設備上的sqlite數據庫。 – 2011-02-12 14:52:58