I am working in Android, in case that matters. The latter syntax is a little more concise, but I want to know if the result is somehow different (aside from the ON UPDATE CASCADE, which of course has an effect I only included it because I copied the code exactly from the referenced site, and because I don't know that the above syntax doesn't apply only when making such a specification). It also has two foreign keys, one to the Track table and one to the Playlist table. c.execute ('''CREATE TABLE IF NOT EXISTS classes ( ClassID PRIMARY KEY, User text, FOREIGN KEY (User) REFERENCES users (UserID)))''') However, I would question the design. The below example will use a SQLite connection with Chinook database. ![]() To fix the error, add User to your table definition. Trackartist INTEGER REFERENCES artist(artistid) ON UPDATE CASCADE As you did not add a field User to your table, you got the error: unknown column 'User' in foreign key definition. ![]() However, from the same site ( ) I see this: CREATE TABLE artist( The final step in adding a new foreign key to a SQLite database is to run VACUUM, to ensure the new foreign key is available in future introspection queries. ![]() Mostly I've seen the following (from ): CREATE TABLE artist(įOREIGN KEY(trackartist) REFERENCES artist(artistid) I'm creating a table with foreign key references.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |