auto-increment in a db without auto-incrememnt param

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

auto-increment in a db without auto-incrememnt param

Post by Luke »

I am working with some proprietary database that stores its databases in dbf format. I'm pretty sure you can't assign an auto-increment parameter to a field. How would you increment a column without that?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Use MAX(), if that's possible, and just assign to the next row MAX() + 1.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I guess the system I'm working on has a table called StoreKeys and every other table that needs an auto-increment value has a record in this table. There is a column called "maxvalue" that you use for the table's id values. Seems open for bugginess if you ask me.
Post Reply