Rename Column — SQL Technical Interview Questions & Answers
Rename Column
Rename Column
- MySQL 8: ALTER TABLE students RENAME COLUMN marks TO score; Older: ALTER TABLE students CHANGE marks score INT; CHANGE requires the type again — easy to mistype.
- Rename in the app too. ORM field names will break if you only change SQL.
- Trap: CHANGE with the wrong type and silently converting data.
- On the example next to this theory: Rename Column — aLTER TABLE changes structure without rebuilding the whole table.
Technical Interview Tip: ALTER TABLE students RENAME COLUMN marks TO score;
Code Examples for Rename Column
Rename Column — sample query
CREATE TABLE items (id INTEGER PRIMARY KEY, title TEXT);
ALTER TABLE items ADD COLUMN price REAL DEFAULT 0;
INSERT INTO items (id, title, price) VALUES (1, 'Pen', 10);
SELECT * FROM items;Rename Column — aLTER TABLE changes structure without rebuilding the whole table.
How to Explain Rename Column to an Interviewer
How do you rename a column in MySQL 8?
ALTER TABLE t RENAME COLUMN old TO new;