Revisiting ALTER COLUMN POSITION support

Started by Daniel Cyranabout 1 year ago2 messageshackers

Thread notes

1 note#feature#moderate
hackorum-bot#feature#moderate
hackorum-bot
1 day ago

@global #feature #moderate

#feature#moderate
Jump to latest
#1Daniel Cyran
danielcyran95@gmail.com

Hi,

I'd like to reopen the discussion about adding support for reorderable
columns (e.g. ALTER COLUMN POSITION or ALTER COLUMN ... AFTER ...).

This request has existed for many years, and there is already a documented
outline and reasoning here:
https://wiki.postgresql.org/wiki/Alter_column_position
<https://wiki.postgresql.org/wiki/Alter_column_position?utm_source=chatgpt.com>

The lack of this feature becomes a real issue in long-term schemas with
large and evolving tables. While PostgreSQL assumes column order is
cosmetic, in real-world environments the ability to logically group and
reorder columns significantly improves maintainability, onboarding, query
readability and workflow efficiency — especially when tables grow over
several years and may contain dozens or hundreds of fields.

Other major databases provide this functionality (MySQL, MariaDB, SQL
Server, Oracle), and PostgreSQL is increasingly used in large SaaS systems
and enterprise environments where schema evolution and human readability
matter.

I understand this requires internal architectural work (physical vs logical
ordering identifiers), but since the request keeps resurfacing, I'm asking
whether this can be reconsidered for a future release — or if there is any
active discussion, proposal or roadmap direction related to it.

Thanks.

#2Alvaro Herrera
alvherre@kurilemu.de
In reply to: Daniel Cyran (#1)
Re: Revisiting ALTER COLUMN POSITION support

Hello Daniel,

On 2025-Nov-28, Daniel Cyran wrote:

I'd like to reopen the discussion about adding support for reorderable
columns (e.g. ALTER COLUMN POSITION or ALTER COLUMN ... AFTER ...).

Yeah, I've been planning to work on this after completing the REPACK
project -- I have an old patch for this that I need to rebase and
complete. I suspect it has become substantially harder now that the
backend has moved forward 10 years. I suspect it's going to be quite
challenging.
/messages/by-id/20141209174146.GP1768@alvh.no-ip.org

Somebody else also tried to work on this a couple of years ago, but I
think they got discouraged or something (most likely because of us
moving the goalposts or whatever).
/messages/by-id/20220628083230.c4qhp4fdp3dp22ig@jrouhaud

Regards

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"I can see support will not be a problem. 10 out of 10." (Simon Wittber)
(http://archives.postgresql.org/pgsql-general/2004-12/msg00159.php)