sqlite doesn’t support more than one primary key in one table

This cost me several hours today.

Postgresql support multiple primary keys in one table, and I took granted that sqlite does the same thing when I did some prototype today.

And they have a good reason explained in the SQLite CVSTrac.

The odd thing is, if I specify two primary keys in sqlite, it won’t complain when creating the table, but complains that one of the primary key can’t be NULL when I do a insert. This lead me to a wrong way :(

The solution is easy when I found the problem: use the unique keyword instead of primary key.

Tags: , ,

Post a Comment

You could use <code type="name"> to get your code colorized

Your email is never published nor shared. Required fields are marked *

Close
E-mail It