Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2003
    Posts
    19

    Unanswered: autoincrement column is odd numbers

    Hello,
    I was looking at one of my tables and I noticed that the autoincrement on the column was incrementing by two and not 1. So all of the row id numbers are odd (e.g. 1,3,5,7...).

    Is there a config setting that I did to make this happen?

    Thanks!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    your script to insert new rows is actually executing the INSERT statement twice, but the duplicates are getting rejected, and you don't notice it because you have IGNORE as an option on the INSERT statement
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Aug 2003
    Posts
    19
    So, how do I know that it's adding data twice? Can I look in a log to verify this?

    Thanks!

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by sunfire View Post
    So, how do I know that it's adding data twice?
    try adding a few rows directly into mysql, i.e. outside of your app

    if they increment by 1, then it's your app that has the problem
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Aug 2003
    Posts
    19
    I just used AquaData Studio and inserted a new row and I still get the increment of 2.

  6. #6
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    [wild shot in the dark]Are there any triggers on the table?[/wild shot in the dark]

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What does this return:
    Code:
    SELECT auto_increment
    FROM   information_schema.tables
    WHERE  table_name = '<table_name>'
    George
    Home | Blog

  8. #8
    Join Date
    Aug 2003
    Posts
    19
    Here is what I get back

    auto_increment
    -----------------
    (null)
    64

    2 record(s) selected [Fetch MetaData: 2/ms] [Fetch Data: 0/ms]

    [Executed: 1/5/10 8:58:53 AM PST ] [Execution: 4/ms]

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    please see MySQL :: MySQL 5.1 Reference Manual :: 16.1.3.2 Replication Master Options and Variables

    i've never worked with master/slaves so i'm not familiar with this server setting, and i don't know if it can be applied to a single server

    but at least this would explain the weird behaviour
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •