There is a table which had records but these records were deleted. There is a primary key which is incremented automatically on the database table.
Is there a way to know , before inserting a new row in the table , the next value of this primary key ? If it is not possible is there a way to get the immediately the value of the generated primary key after inserting a row ?
You could insert a row and then look at
last_insert_id:That would give you the
auto_incrementvalue that was used for the INSERT.You can also try looking at the
show table status like 'your_table_name'output, there will be an Auto_increment value that should tell you the next one that will be used.