title: Resort MySQL Table by Column Alphabetically
body: <p>I have table containing settings for an application with the columns: <em>id</em>, <em>key</em>, and <em>value</em>.</p>
  
  <p>The <em>id</em> column is auto-incrementing but as of current, I do not use it nor does it have any foreign key constraints. I'm populating the settings and would like to restructure it so they are alphabetical as I've not been putting the settings in that way, but reordering alphabetically would help group related settings together.</p>
  
  <p>For example, if I have the following settings:</p>
  
  <pre><code>ID     KEY             VALUE
  ======================================
  1      App.Name        MyApplication
  2      Text.Title      Title of My App
  3      App.Version     0.1
  </code></pre>
  
  <p>I would want all the App.* settings to be grouped together sequential without having to do an ORDER BY everytime. Anyway, thats the explanation. I have <a href="https://stackoverflow.com/questions/1850594/mysql-how-to-reorder-a-table">tried the following</a> and it didn't seem to change the order:</p>
  
  <pre><code>CREATE TABLE mydb.Settings2 LIKE mydb.Settings;
  INSERT INTO mydb.Settings2 SELECT `key`,`value` FROM mydb.Settings ORDER BY `key` ASC;
  DROP TABLE mydb.Settings;
  RENAME TABLE mydb.Settings2 TO mydb.Settings;
  </code></pre>
  
  <p>That will make a duplicate of the table as suggested, but won't restructure the data. What am I missing here? </p>