Обсуждение: Revisiting ALTER COLUMN POSITION support

Поиск
Список
Период
Сортировка

Revisiting ALTER COLUMN POSITION support

От
Daniel Cyran
Дата:

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

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.

Re: Revisiting ALTER COLUMN POSITION support

От
Álvaro Herrera
Дата:
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.  
https://postgr.es/m/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).
https://postgr.es/m/20220628083230.c4qhp4fdp3dp22ig%40jrouhaud

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)