Python Forum

Full Version: mysql id auto increment not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
For an empty table, as yet no data, set:

Quote:ALTER TABLE allstudents21BE3 AUTO_INCREMENT = 0;

After that, the unique key column will continue to auto-increment each time you enter a new row of data, you don't need to put it in an INSERT query.

I did that just this morning, because I had to add 3 new students to my table, no need to mention the unique key column id:

Quote:INSERT INTO allstudents21BE( studentnr, name, email, password, max_attendance, attendance, has_been_inc, attn_this_week) VALUES (1825010344, '不知道', 0, 0, 0, 0, 0, 0)
If you delete rows, the AUTO_INCREMENT still stays at the last value, nothing changes, but that doesn't matter, the unique key column doesn't need to be continuous, it only needs to be unique! Best leave it alone.
Pages: 1 2