On Wed, Apr 25, 2001 at 12:50:05PM +0100, Mark Fowler wrote:
> On Wed, 25 Apr 2001, David Cantrell wrote:
>
> > Trouble is, they all have non-standard extensions, which are *really* handy
> > and which you *will* use if you don't know any better. For example, MySQL
> > has AUTO_INCREMENT fields which are dead useful for id fields; the closest
> > Oracle equivalent would be using a sequence.
>
> Why you say don't know better, what should I use instead of this.
The portable way to do it is the slow way. That's why the vendors went
and extended the language. The real problem is that they generally don't
document very well what's standard and what's proprietary, so you need to
be familiar with at least a couple of rdbms's to know what's what.
TBH though, I would use postgresql instead of mysql anyway. It's far more
capable, but is also closer to the Oracle way of doing things.
> Is
> there any sensible way to do this in bog standard SQL that won't have a
> massive perfomance hit on mysql?
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.
--
David Cantrell | [EMAIL PROTECTED] | http://www.cantrell.org.uk/david/
Rip, Mix, Burn, unless you're using our latest and greatest
operating system which we couldn't be arsed to complete