I have a table with unsorted rows and want to make them sorted by column. I want the table to be sorted by column, so I create a sort_by column.
Now the table looks like this:
ID Data sort_by
-- ----- -------
27 Blahh 1
54 Blahh 2
57 Blahh 3
1 Blahh 4
Now I want to insert a row in the second position (sort_by = 2). Then I will have to update sort_by for all rows> 2 with sort_by + = 1. This is a lot of updates if I have several million rows.
So, is there a canonical way to do this? Of course, I could take big steps between columns and insert new lines into spaces, etc., But is there an aesthetically pleasing way, i.e. Not a hack?
Sorting is done manually by users. A good phrase for google for = upvote, all I'm trying to do is open ways to sort the table in some DBMSs or some frameworks. :)
source
share