0
我想在onCreate()方法中創建一個表,但sqlite拋出異常,語法錯了。但如果我在Firefox SQLite管理器中嘗試相同的查詢,它創建表成功。不知道是什麼毛病我code.The查詢如下:創建表上的Android sqlite異常
CREATE TABLE playlistSongs(
id INTEGER PRIMARY KEY,
playlist_id INTEGER,
FOREIGN KEY(playlist_id) REFERENCES playlists(id) ON DELETE CASCADE,
song_id INTEGER,
FOREIGN KEY(song_id) REFERENCES songs(id) ON DELETE CASCADE);
的例外是:
11-22 16:44:58.066: E/AndroidRuntime(11241): Caused by:
android.database.sqlite.SQLiteException: near "song_id": syntax error:
CREATE TABLE playlistSongs(id INTEGER PRIMARY KEY,playlist_id
INTEGER,FOREIGN KEY(playlist_id) REFERENCES playlists(id) ON DELETE
CASCADE,song_id INTEGER,FOREIGN KEY(song_id) REFERENCES songs(id) ON
DELETE CASCADE);
什麼'PRAGMA compile_options的結果;'在兩個數據庫? –
什麼是PRAGMA compile_options; ?我真的不知道這個以及如何使用它? – Anshul
我認爲你應該在最後申報外鍵 – njzk2