Renaming

ALTER TABLE ... RENAME COLUMN

Instant metadata-only on PostgreSQL 14+; still takes ACCESS EXCLUSIVE with no non-blocking alternative pre-14

Lock mode ACCESS EXCLUSIVE
Risk LOW
Blocks reads, writes, other DDL
pgfence rule rename-column
ALTER TABLE orders RENAME COLUMN status TO order_status;

What this does

A pure catalog rename, no table scan or rewrite. On PostgreSQL 14 and later the ACCESS EXCLUSIVE lock is brief and metadata-only. On earlier versions the lock mode is the same but there is no non-blocking alternative available, so plan for a maintenance window or use expand/contract if the rename must be zero-downtime.

Read more

More in Renaming