Menu

1 / 3

Renaming a Column: What Breaks on PostgreSQL, MySQL, SQL Server and SQLite

DEV Community: mysql·Son Tran·7 days ago
#oZqeEqFH
#devtomysql#devto#dev#column#rename
Long article (3103 words) — no AI summary yet.
Reading 0:00
15s threshold

Disclosure: I build Schemity , a desktop ERD tool - this post is from our blog and uses it for the examples.

TL;DR: A column rename is a quick metadata change on every database, but what it does to the objects that read the column differs. PostgreSQL and SQLite rewrite views, checks, generated columns and indexes to the new name; MySQL and SQL Server refuse the rename while a CHECK or generated column reads the column, and let it through while leaving views broken. On every engine but SQLite, a trigger or routine body can fail on its next run, so list what reads the column before you rename it.

Renaming a column is safe for the data and unsafe for everything that reads the column by name, and each database draws that line in a different place. PostgreSQL and SQLite rewrite views, CHECK constraints, generated columns and indexes to the new name.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.