Column renames metadata only

From CarlosCaPe/octorato · View interactive version

Column renames metadata only is an AI agent skill from the GitHub repository CarlosCaPe/octorato. Column Renames (Metadata-Only)

How to use this skill

Skill file

Column Renames (Metadata-Only)

What

PostgreSQL's ALTER TABLE RENAME COLUMN is a metadata-only operation. It

changes the column name in the system catalogs (pg_attribute) without touching

the actual table data. It's instant regardless of table size.

Why

This matters because renaming a column on a 100-million-row table takes the

same time as renaming one on a 10-row table: effectively zero. No table rewrite,

no data movement, no downtime.

How

ALTER TABLE public."Applicant"
    RENAME COLUMN "SpeialtyRequirement" TO "SpecialtyRequirement";

What happens internally:

  1. PostgreSQL acquires an ACCESS EXCLUSIVE lock on the table (very briefly)

-- this is the strictest lock mode but the hold time is sub-millisecond

since only catalog metadata is updated (PG 16 docs: sql-altertable.html)

  1. Updates pg_attribute.attname for that column's OID
  2. Releases the lock

Total time: typically < 1ms.

What It Does NOT Do

This is why had to separately update 4 stored procedures -- the column

rename alone would have left them broken with "column does not exist" errors.

When to Use

Where We Used It

Related Skills

Gotchas


Category: DDL | Origin:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.