On Wed, Oct 22, 2008 at 2:16 PM, cfobel <[EMAIL PROTECTED]> wrote: > Does anyone definitively know whether MySQL automatically increments > its sequences (or whatever their equivalent name is) even if records > are manually inserted with a higher ID?
Seems to: mysql> describe color; +-------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | value | varchar(10) | NO | | | | | warm | tinyint(1) | NO | | | | +-------+-------------+------+-----+---------+----------------+ 3 rows in set (0.02 sec) mysql> insert into color (value, warm) values ('Red', 1); Query OK, 1 row affected (0.00 sec) mysql> insert into color (value, warm) values ('Blue', 0); Query OK, 1 row affected (0.00 sec) mysql> select * from color; +----+-------+------+ | id | value | warm | +----+-------+------+ | 1 | Red | 1 | | 2 | Blue | 0 | +----+-------+------+ 2 rows in set (0.00 sec) mysql> insert into color (id, value, warm) values (8, 'Orange', 1); Query OK, 1 row affected (0.00 sec) mysql> insert into color (value, warm) values ('Green', 0); Query OK, 1 row affected (0.00 sec) mysql> select * from color; +----+--------+------+ | id | value | warm | +----+--------+------+ | 1 | Red | 1 | | 2 | Blue | 0 | | 8 | Orange | 1 | | 9 | Green | 0 | +----+--------+------+ 4 rows in set (0.00 sec) This is with MySQL server 5.0. Before depending on the behavior I'd probably want to carefully read the docs about auto increment: http://dev.mysql.com/doc/refman/5.1/en/example-auto-increment.html Also, in your situation I don't know I'd be considering switching DBs to avoid the error you hit. If I understand correctly, though you did not intentionally manually assign IDs that should have been auto-generated, somehow the sequence got out of sync with what was in the DB. I'd really want to understand how that happened and fix the root cause. Whatever it is that manually assigned IDs might cause worse problems down the road (overwriting existing objects with new, doing unexpected things when a manually assigned ID overlaps an already-in-use one, using an ID so high that MySQL runs out of possible values, etc.). I think I'd rather know sooner rather than later that something screwy is going on with the auto-id fields, myself, and it sounds like PostgreSQL will likely report the problem sooner. Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---