'auto_increment' in PostgreSQL
Posted on 2003-11-09
I'm working on converting a PHP/MySQL application to a PHP/PostgreSQL app.
I need help with the auto_increment.
I've read through the source code of a few scripts that support MySQL, and PostgreSQL, and noticed that they overcame the problem using Sequences.
The problem is that when I insert a row, from a dump, that has all the values present(including the id), the sequence isn't incremented, so then when I try to insert a row, without stating the id, it trys to use the first of the sequence which is the same as a value already in the db, which results in an error, in havig two values for the same primary key.
Is there any way for me to set a default of the highest number already in the database + 1?
While I'm here, and this isn't strictly part of the above question, but I'd like to know if this will be a problem with other DB systems, such as Oracle, Access, SQL Server, etc
I think this is a fairly simple question. If that proves not to be the case I'll up the point value.