column-renames-metadata-onlylisted
Install: claude install-skill CarlosCaPe/octorato
# 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
```sql
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)
2. Updates `pg_attribute.attname` for that column's OID
3. Releases the lock
Total time: typically < 1ms.
## What It Does NOT Do
- Does NOT update stored procedures that reference the old column name
- Does NOT update views that reference the old column name
- Does NOT update application code
- Does NOT update indexes (indexes reference column attnum, not name)
- Does NOT change parameter names in function signatures
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
- Fixing typos in column names
- Standardizing naming conventions
- Any