Re: Reordering the fields in a table

From: Thomas Kellerer <shammat(at)gmx(dot)net>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Cc: mike(dot)moening(at)rtssigns(dot)com
Subject: Re: Reordering the fields in a table
Date: 2021-04-17 15:29:33
Message-ID: c51cdb49-d564-b4d9-19dd-895408cf5665@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

mike(dot)moening(at)rtssigns(dot)com schrieb am 17.04.2021 um 16:32:
> MS SQL Server allows this too. I do it all the time.

SSMS will do that for you by dropping and re-creating the table (and all related foreign keys)

But there is no SQL statement to do it.

See e.g. the manual:

https://docs.microsoft.com/en-us/sql/relational-databases/tables/change-column-order-in-a-table?view=sql-server-ver15#TsqlProcedure

> To change the column order
> This task is not supported using Transact-SQL statements.

> Wells Oliver schrieb am 17.04.2021 um 00:28:
>> If it helps the cause, I would love this too, in addition to having
>> the ability to ALTER TABLE ... ADD COLUMN with the ability to specify
>> where in the column order. This ends up being a bigger frustration for
>> a lot of people than it should be, and maybe it's a touch of OCD, but
>> most RDBMS packages allow this
>
> "Most" seems a bit of a stretch.
> To my knowledge it's only supported in MySQL, Firebird and Informix.
>
> You can't do this in Oracle, SQL Server, DB2, Teradata, Ingres, Vertica or SAP Hana.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2021-04-17 15:40:30 Re: Reordering the fields in a table
Previous Message David G. Johnston 2021-04-17 15:21:34 Re: Reordering the fields in a table