i'm trying retrieve last_insert_id
following statements after inserting new record, works fine.
select last_insert_id();
the problem
when inserting new record in table , restart mysql server , trying retrieve last_insert_id
, gets 0
value!
last_insert_id
works before restarting mysql or rebooting system ?
any appreciated.
as stated in mysql docs,
the id generated maintained in server on per-connection basis. means value returned function given client first auto_increment value generated recent statement affecting auto_increment column client. value cannot affected other clients, if generate auto_increment values of own. behavior ensures each client can retrieve own id without concern activity of other clients, , without need locks or transactions.
which means - after restart set of statements there no statement affecting auto_increment value, value undefined.
Comments
Post a Comment