Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sort a MYSQL table in a permanent way?

Tags:

I am a having a table with column Symbol and Weight(only two Column) . I need to sort table according to weight of the symbols, that i can do by

SELECT symbol, weight FROM symbols ORDER BY weight DESC 

but this wont change my table, but it will give me a sorted output(temporary).

I want to sort table permanently. How can i do that?

like image 393
CyberBoy Avatar asked Nov 06 '13 23:11

CyberBoy


1 Answers

You can do this with ALTER TABLE

f.e.

ALTER TABLE tablename ORDER BY columnname ASC;. 

but be aware that the table does not remain in this order after inserts and deletes

like image 171
Jannic Beck Avatar answered Oct 05 '22 05:10

Jannic Beck