Ad space (banner)
🗄️SQL Lessons
Lesson 22 / 50

Changing Table Structure with ALTER TABLE

This lesson covers changing a table's structure with ALTER TABLE, so you can add a new column to a live database. It's for anyone searching "SQL ALTER TABLE tutorial."

ALTER TABLE table ADD COLUMN name type adds a column after the fact — a routine operation once a system is already running and its data shape needs to grow.

The example starts with a students table that only has id and name, then adds a new grade column with ALTER TABLE students ADD COLUMN grade INTEGER;. Watch how the table's shape changes without any existing data being lost.

A common early mistake is expecting a value in the new column immediately — every existing row gets NULL for a newly added column, so if you need a uniform value everywhere, you have to follow up with an UPDATE. "We need to store one more piece of information" is a request every growing product hears eventually, and being able to change structure without losing existing data is exactly what ALTER TABLE is for.

SQL
OUTPUT

💡 The SQL engine may take a few seconds to load the first time you run code.

Ad space (banner)
Ad space (in-article)