On Fri, Apr 27, 2001 at 07:57:04AM +0100, Piers Cawley wrote:
> David Cantrell <[EMAIL PROTECTED]> writes:
> > Unfortunately no. You'd have to:
> > LOCK the table
> > SELECT the maximum id currently in use and add one
> > INSERT with that id
> > UNLOCK the table
> > so all your other queries will block until the table is unlocked.
>
> Create a 'seq' table associated with each table that needs
> autoincrement.
>
> LOCK that table.
> SELECT the one entry that is the next value in the sequence.
> UPDATE the entry with an incremented value.
> UNLOCK the sequence table
>
> INSERT into data table using the id you got from the other table.
> Which looks to me like it should be faster.
The real answer is since you are using a database you care about speed
so spend three minutes reading the docs/google for your particular
database vendor and implement whatever strategy is suggested
(AUTO_INCREMENT, ROWID, oid, SEQUENCE, before-row-insert triggers,
etc).
Paul