It's a large db and it's really messy, I would like to order all columns in all tables, without resorting to manual drag and drop...

EDIT I know the order doesn't matter. It's a design think. It will be much easier to read and to find things if they are ordered. ,I have also many columns like "is_visible", "is_editable" etc... if they are all together it looks better.

  • Do you mean columns order in a table structure ???
    – Akina
    Feb 20, 2020 at 12:49
    – Luuk
    Feb 20, 2020 at 13:18

4 Answers 4


No need to order. And thinking of ordering by all columns is pretty much problematic. You will create a bigger mess than...

Just create a view for each of your requirement.

create or replace view db1_name_wise as 
  (select required_field_list from db1 order by name);

And create as many views as you wish.

  • hmm maybe this could be a nice solution
    – Glasnhost
    Feb 20, 2020 at 16:35
  • And if you notice, the views are always ready to access - gets updated real time - always read-only - you shall think them of a layer above all your dbs which can be accessed by any higher level code. Feb 20, 2020 at 16:41

I would like to order all columns in all tables

The order of column [names] within a Table should not matter.

Every "select" statement that goes anywhere near your database should explicitly specify the columns that it wants, in the order that it wants them. How the actual table is arranged matters not a jot.

If you have lots of columns with similar names, this may be indicative of a larger problem.


The order doesn't matter, because table are by definition unordered.

I also like it Tight and Needy in an order, but if the database grows it is unavoidable.

If you really want it and i stress the words really want it, you can always Create a new table and use INSER INTO..SELECT, but this would only work if the related tables don't use uuid or auto_increment value for reference

And then delete the old table and rename the new one table.

But that would be a lot of work, without any benefit for the database and can cause a lot of problems, because this must be tested in a non production enviromenbt and never on a live system.


This is all about the SELECT QUERY and the ORDER BY keyword i recommend you to read about ORDER BY in w3Schools

And if you are starting with SQL database you might read some CRUD commands documentation :)!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.