我正在尝试在 onCreate() 方法中创建一个表,但 sqlite 抛出语法错误的异常。但是如果我在 Firefox SQLite Manager 中尝试相同的查询,它会成功创建表。我不知道我的代码有什么问题。查询如下:
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);