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 731 Oct-03-2023, 10:25 PM
Last Post: lostintime
  help to increment a third list hermine 7 1,384 Nov-29-2022, 04:19 PM
Last Post: perfringo
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,281 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  Character Increment AnokhiRaaz 1 2,527 Apr-22-2021, 04:29 AM
Last Post: buran
  Increment text files output and limit contains Kaminsky 1 3,244 Jan-30-2021, 06:58 PM
Last Post: bowlofred
  Increment formula Kristenl2784 4 2,923 Jul-20-2020, 10:14 PM
Last Post: Kristenl2784
  [openpyxl] Increment cells being pasted into Template Kristenl2784 4 3,613 Jul-16-2020, 10:00 PM
Last Post: Kristenl2784
  How can I increment a List item with in a "for in" msteffes 4 3,604 Aug-14-2019, 08:55 AM
Last Post: DeaD_EyE
  How define iteration interval increment SriMekala 5 4,412 Jun-01-2019, 01:06 PM
Last Post: ichabod801
  SQlite3 quickly increment INT value? jmair 1 2,479 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