On 15 Feb 2011, at 11:28pm, Drake Wilson wrote:

> Quoth Maciej Lotkowski <maciej.lotkow...@gmail.com>, on 2011-02-15 23:28:01 
> +0100:
>> Is it possible to have composite primary key where one column is
>> autoincrement? From what I found in docs it looks like it is possible
>> to have either simple primary key on one autoincrement column or
>> composite PK on few columns without autoincrement. Am I right? If no,
>> what is the syntax to create a table with primary key "id" and
>> "another_id" where "id" is autoincrement?
> 
> When would it make sense to do this?  What value would another_id take
> if you try to insert with both of them null?  More generally, could
> you show some example inserts with what behavior you expect?  I
> suspect what you're looking for is best done some other way.

Or to put it another way, if a column is autoincrement and you don't intend to 
mess with the values manually, it's going to be unique anyway, so it makes a 
good simple short primary key.  You may have good reasons to make another index 
on the combination of columns, though.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to