I have connected with my database through two programs: MySql Workbench and Sequel Pro (It's a ClearDB MySQL database hosted on heroku). I have created a simple table:
CREATE TABLE Country(
CountryID int AUTO_INCREMENT NOT NULL,
Name varchar(50),
PRIMARY KEY(CountryID)
);
and then I added a few entries:
INSERT INTO Country(Name) VALUES ("Poland");
INSERT INTO Country(Name) VALUES ("Germany");
INSERT INTO Country(Name) VALUES ("Sweden");
INSERT INTO Country(Name) VALUES ("France");
the problem is when I do SELECT * FROM city
, I get the results as below, where the PRIMARY KEY is being auto incremented in alphabetical/lexicographical order:
1, Poland
21, Germany
31, Sweden
41, France
And I want the PRIMARY KEY to be 1, 2, 3, 4 etc.
I can't find any settings for that, nor any posts that would suggest why is this happening. Anyone has got any clue?
I don't understand what you mean by this:
the problem is when I search for the contents in this table they are being created with PRIMARY KEY in alphabetical/lexicographical order
But based on your sample data, the keys are being assigned in the order that the data was entered, which is exactly what one would expect. As to why there are jumps of ten between key values, it's intentional on the part of ClearDB:
ClearDB uses circular replication to provide master-master MySQL support. As such, certain things such as auto_increment keys (or sequences) must be configured in order for one master not to use the same key as the other, in all cases. We do this by configuring MySQL to skip certain keys, and by enforcing MySQL to use a specific offset for each key used. The reason why we use a value of 10 instead of 2 is for future development.