SQL column reordering

I have created a Table with various parameters that store values. There values are displayed in column charts in a particular order from left to right. Sometimes it is necessary to add a parameter to the Table, but I dont want it to be displayed in the chart last, but rather at a position within the table. For some reason Column reordering in not supported in SQL.
IS there a way around it? Perhaps design my software in a different way regarding Table design in order to be able to accomplish this?

In theory a relation (table) is an unordered set. Most people recognize that rows are unordered but in theory columns are also unordered. In practice, I have never seen a relational database where SELECT * does not order the rows in the order they were defined.

It is good practice to always list the columns you want in the order you want in the SELECT clause.

If you really want to reorder the columns in SELECT * then you will need to create a new table, copy the data from the original table and then rename the tables. Doing this is rarely needed although it can sometimes help slightly with performance. Another approach is to create a VIEW with the columns in the order you want.

1 Like

Rename the original table, then create a view, with the original table name, that lists the columns in any order you want.