Jump to content

Recommended Posts

I recently upgraded to the latest MySQL version.  I noticed when I run a query such as SELECT * FROM table it no longers order by the auto_incrementing ID ASC by default.  I have to tell it to do that.  Instead, it orders alphabetically by the next field.  Is there a way I can change the config to order by ASC by default when selecting everything?

You can't "trust" the order when ORDER BY is not specified, you must specify the ORDER BY if you want a specific order.

 

depending on the DB storage engine used to store the table you can get completely different results... in Innodb per example the order could be the PRIMARY KEY.

In MyIsam the order could be the Insertion order if the table never have had updates/deletes/replaces... otherwise order will be anything.

 

Is not setup available to define the default order in any storage engine AFAIK.

 

if you updated your db recently and you are seeing different order than before probably the storage engine is now Myisam instead of Innodb for the affected tables.

 

the rule of thumb: Never trust in "default order" because there is not such reliable thing... always use and ORDER BY if you want a specific order.

 

just forgot to mention that in MyIsam an option exist (but I personally never use/trust on) which is:

ALTER TABLE ORDER BY <column name>

but it is used only for creation... order is not maintained after updates/deletes/refresh

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.