Hi.

On Thu, Dec 13, 2001 at 12:14:27AM -0800, [EMAIL PROTECTED] wrote:
> The manual states:
> 
> "Normally, you don't have to lock tables, as all single UPDATE
> statements are atomic; no other thread can interfere with any other
> currently executing SQL statement."
> 
> Does this hold true for INSERT ... SELECT statements as well?

Yes. "... with /any/ other currently executing SQL statement"

> Can I assume that multiple records inserted into a table with a
> single statement will have a perfectly sequential primary key in an
> auto_increment field,

I would say, yes. I don't know whether it is assured, that
auto_increment will create sequence without gaps, but currently the
behaviour is this way.

> or is there a possibility that another insert at the same time could
> interefere with my statement such that I should lock the table
> before I begin if I need to guarantee no gaps in the sequence?

No. Explicit LOCKs are only needed at all if you issue several
statements. If you only issue one command, MySQL will implicitly
aquire appropriate locks.

> If I must lock, can I then be absolutely confident there will be no
> gaps?  I need to update a different table based on the values
> assigned to the newly inserted records.

Well, if you want to be absolutely safe, you can always select the
inserted rows... ;-)

Bye,

        Benjamin.

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to