Re: Rearrange Column - Mailing list pgadmin-support

From richard coleman
Subject Re: Rearrange Column
Date
Msg-id CAGA3vBvgz_NC2LbVAU_EjxNEGTw4UgPwc05k7Y8i2ghFMyWA-g@mail.gmail.com
Whole thread Raw
In response to Re: Rearrange Column  (Dave Caughey <caugheyd@gmail.com>)
List pgadmin-support
Dave, 

Thanks, yes I got that, and the OP may indeed have wanted info on the reporting results.  Since pgAdmin4 lets one administer/create/manipulate the postgreSQL database/tables/views/etc. rearranging the underlying table (much like Microsoft SQL Management Studio lets you do with a MS MQL database table) was how *I* interpreted the question.

Since each table has a unique column structure, for pgAdmin4 to allow one to specify a custom "SELECT * from Foo;" output would require it to have a UI specific to each table for ordering and/or renaming each column, a menu item to let the user run the custom select view and a place in a *pgAdmin4* specific database to store all of this.  If there were any changes to the table structure after that, it would have to check and inform the user or risk throwing an error.  Seems like an awful lot of work.

If the OP wanted to have a custom view, wouldn't it make more sense to do just that?  Create a custom postgreSQL view; "SELECT {fields in order and optionally renamed as wanted} from Foo;"  Then all the user would need to do is to use the bog standard pgAdmin4 "View/Edit Data" menu item to view it in the preferred order anytime OP wanted to.

Just my $0.02.

rik.




On Thu, Apr 22, 2021 at 11:25 AM Dave Caughey <caugheyd@gmail.com> wrote:
Rik,

Clearly, if you do

SELECT colA, colB FROM MyTable

vs 

SELECT colB, colA FROM MyTable

you'll get the results in a different sequence.  Obviously, using this approach has not manipulated the underlying table (your interpretation of what the OP is asking for), but perhaps the OP's question is that they're wondering if the *reporting* tool (i.e., pgAdmin) could hopefully allow you to rearrange the sequence in which a table's columns are displayed so that when you do a 

SELECT * FROM MyTable

pgAdmin will take care of manipulating the results of the query to *display* the columns in a specified sequence.

Yes, the OP currently has the ability to craft a custom query, e.g., 

SELECT colA, colB, colZ, colT, colC, colQ, colD, colE... 

to get the exact order they want, but it would actually be nice if the reporting tool took care of this for you so you could just specify "SELECT *" and get the columns in the way you want to see them, or, should they be using "View/Edit Rows" pgAdmin would again show the rows in the prefered order.
 
Cheers,
Dave


On Thu, Apr 22, 2021 at 11:01 AM richard coleman <rcoleman.ascentgl@gmail.com> wrote:
Sachin, 

Umm, I hate to be the one to break it to you, but postgreSQL doesn't support rearranging columns in a table, short of dropping them and re-adding them in the desired order.  Since postgreSQL itself doesn't support that, I would be truly amazed to learn that pgAdmin4 managed to accomplish that trick.

If I'm wrong, someone *please* let me know.

rik.

On Thu, Apr 22, 2021 at 9:53 AM Sachin Kumar <sachinkumaras@gmail.com> wrote:
Hi Team,

How can we rearrange the column of PostgreSQL using PGADMIN?

--

Best Regards,
Sachin Kumar

pgadmin-support by date:

Previous
From: Dave Caughey
Date:
Subject: Re: Rearrange Column
Next
From: Rahul Shirsat
Date:
Subject: Re: Error while starting PgAdmin 5.0