Please add the ability to add columns into the middle of a table.

From: Patrick Headley <pheadley(at)linxco-inc(dot)com>
To: pgadmin-support(at)postgresql(dot)org
Subject: Please add the ability to add columns into the middle of a table.
Date: 2016-05-06 19:18:31
Message-ID: 572CEE07.2080600@linxco-inc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

Having the ability to insert a column in the middle of a table using the
PGAdmin 3 UI would be very nice. Benefits include grouping related
fields and creating a column list in the natural flow of data entry.
Having it automated within the UI would make this piece of DB management
so much easier.

I am able to write scripts that do this but it takes a long time to
write the scripts on tables with lots of dependencies, partly because:
1) Dependencies and constraints have to be dropped first and in the
correct order.
2) Dependencies and constraints have to be recreated in the correct order.

Basically, the scripts I write perform these steps:
1) Drop constraints. Sometimes I'll also drop a sequence, but not always.
2) Drop dependencies in the correct order. The challenge is getting the
order correct. I have to run the script within a transaction and see
what errors come up. Roll back any changes, fix any errors and try again.
3) Rename the original table.
4) Create a replacement table with the new columns in the position I
choose. I do this by copying the existing table definition first. This
makes it easy to create the new table with constraints, indexes,
permissions and comments.
5) Make sure any sequence used by the table has the correct value.
6) Drop the original table.
7) Rebuild dependencies (in the correct order).

--
*/Patrick Headley/*
Linx Consulting, Inc.
pheadley(at)linxco-inc(dot)com
www.linxco-inc.com

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message David G. Johnston 2016-05-06 19:24:25 Re: Please add the ability to add columns into the middle of a table.
Previous Message Leto, Justin (Contractor) 2016-05-02 18:32:31 PgAdmin crashing on Mac