Postgres: Reordering table columns.

[expired user #8249]'s profile image [expired user #8249] posted 10 years ago in General Permalink
The Heidi mechanism for reordering table columns does not work with Postgres (pg).
Looking at the pg forums, it appears that this has always been an issue in pg, and that the only real workaround is to re-create the table or a view using a query with the all of the columns in the required order. Tedious, with a lot of columns. But then again, does it really matter what the column order is?
I think column re-ordering functionality was included in MySQL as an extension.
arucard's profile image arucard posted 10 years ago Permalink
In Postgres to change column order is only by recreating table or creating view, just like you mentioned.

There is no way how to change order on created table.

Column order is only useful when you look on data via some grid and you want some consistency.
[expired user #8249]'s profile image [expired user #8249] posted 10 years ago Permalink
The feature will need to be disabled in some way when using Heidi/Postgres certainly not a pressing issue.
[expired user #8433]'s profile image [expired user #8433] posted 9 years ago Permalink
In my opinion there could be two options as a workaround:

1) automatically change the order of columns in data view as it is now possible by hand (with the hint that the real column order @table isn't changed)
2) automatically create a temporary table with the new column order, import data in 'reordered' table, delete/rename (as backup) old table and rename the temporary table to the original name of the source table

It would be great if it would be integrated at some time, but because it is just a comfort feature as Roger already said a solution or feature deactivation when using Postgres is not a pressing issue.
Code modification/commit from ansgar.becker, 9 years ago, revision 8.3.0.4837
Restrict column reordering to MySQL only. Not supported by MSSQL and PostgreSQL. See http://www.heidisql.com/forum.php?t=16328
ansgar's profile image ansgar posted 9 years ago Permalink
r4837 disables the move up/down buttons for columns in PostgreSQL.

Of course such a temp table approach is possible, but seems like much effort for a feature which is intentionally left away in the PostgreSQL server.
[expired user #8249]'s profile image [expired user #8249] posted 9 years ago Permalink
I would just leave it at that Ansgar. Its not really important.

Please login to leave a reply, or register at first.