Python Forum
mysql id auto increment not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mysql id auto increment not working
#11
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql and mysql.connector error lostintime 2 690 Oct-03-2023, 10:25 PM
Last Post: lostintime
  help to increment a third list hermine 7 1,351 Nov-29-2022, 04:19 PM
Last Post: perfringo
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,134 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  Character Increment AnokhiRaaz 1 2,512 Apr-22-2021, 04:29 AM
Last Post: buran
  Increment text files output and limit contains Kaminsky 1 3,210 Jan-30-2021, 06:58 PM
Last Post: bowlofred
  Increment formula Kristenl2784 4 2,902 Jul-20-2020, 10:14 PM
Last Post: Kristenl2784
  [openpyxl] Increment cells being pasted into Template Kristenl2784 4 3,593 Jul-16-2020, 10:00 PM
Last Post: Kristenl2784
  How can I increment a List item with in a "for in" msteffes 4 3,576 Aug-14-2019, 08:55 AM
Last Post: DeaD_EyE
  How define iteration interval increment SriMekala 5 4,366 Jun-01-2019, 01:06 PM
Last Post: ichabod801
  SQlite3 quickly increment INT value? jmair 1 2,458 Mar-04-2019, 08:03 PM
Last Post: stranac

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020