If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > autoincrement column is odd numbers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-04-10, 12:39
sunfire sunfire is offline
Registered User
 
Join Date: Aug 2003
Posts: 19
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!
Reply With Quote
  #2 (permalink)  
Old 01-04-10, 12:47
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-04-10, 17:48
sunfire sunfire is offline
Registered User
 
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!
Reply With Quote
  #4 (permalink)  
Old 01-04-10, 19:01
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 01-04-10, 19:35
sunfire sunfire is offline
Registered User
 
Join Date: Aug 2003
Posts: 19
I just used AquaData Studio and inserted a new row and I still get the increment of 2.
Reply With Quote
  #6 (permalink)  
Old 01-05-10, 06:56
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
[wild shot in the dark]Are there any triggers on the table?[/wild shot in the dark]
Reply With Quote
  #7 (permalink)  
Old 01-05-10, 07:10
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
What does this return:
Code:
SELECT auto_increment
FROM   information_schema.tables
WHERE  table_name = '<table_name>'
__________________
George
Twitter | Blog
Reply With Quote
  #8 (permalink)  
Old 01-05-10, 11:59
sunfire sunfire is offline
Registered User
 
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]
Reply With Quote
  #9 (permalink)  
Old 01-05-10, 12:54
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On