Re: MySQL <-> Oracle8

From: Date: Mon, 05 Jun 2000 19:00:14 +0000
Subject: Re: MySQL <-> Oracle8
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-1084@lists.php.net to get a copy of this message
>>> "select max(my_auto_increment_field) from mytable"? >> >> That only works if you haven't deleted a record and the auto-increment >> hasn't filled the new vacancy. > > > As I understand it (and testing supports this), the auto_increment > attribute does not fill in vacancies, but rather adds 1 to the current > maximum value of the auto_increment field. > >> From the documentation: > "An integer column may have the additional attribute AUTO_INCREMENT. When you > insert a value of NULL (recommended) or 0 into an > AUTO_INCREMENT column, the column is set to value+1, where value is the > largest value for the column currently in the table." > > In which case, after locking tables to prevent inserts between > your insert query and your id query, the correct insert id would be > returned by the max() function. > > > Any thoughts? I concur that this must be true... However, I seem to remember running into this problem back about a year ago when I tried to do this manually with MySQL (I wasn't aware of the insert_id command at the time). But perhaps it was a different issue and I just remember it incorrectly. -k

« previous php.general (#1084) next »