W3 Schools Alter Table Mastery Complete Guide To SQL Table Modification

Logan Jul 13, 2026

Looking to make changes to your MySQL tables? The ALTER TABLE command is a powerful tool that allows you to modify the structure of your tables. Today, we're going to explore this command with the help of W3 Schools' tutorials and syntax explanations.

Orthodox Christian kids Altar Table, printable activity
Orthodox Christian kids Altar Table, printable activity

Whether you need to add new columns, drop existing ones, or change data types, ALTER TABLE is your go-to command. Let's dive in to understand it better.

the table is set up with legos and books for children to read in front of them
the table is set up with legos and books for children to read in front of them

Understanding ALTER TABLE Syntax

The basic syntax of the ALTER TABLE command is straightforward:

a white table topped with books and a stuffed animal on top of it's shelf
a white table topped with books and a stuffed animal on top of it's shelf
StatementDescription
ALTER TABLE table_nameSelects the table you want to modify
ADD COLUMN column_name data_typeAdds a new column to the table
DROP COLUMN column_nameRemoves an existing column
CHANGE COLUMN old_name new_name data_typeRenames a column and changes its data type

You can also use ALTER TABLE to add or modify keys, indexes, or constraints. However, these operations are more complex and beyond the scope of basic understanding.

Spiritual Altar by front door 🥰🙏🏼
Spiritual Altar by front door 🥰🙏🏼

Adding a New Column

To add a new column, use the ADD COLUMN syntax. For example, to add a 'birthdate' column to an 'employees' table, you might use:

ALTER TABLE employees ADD COLUMN birthdate DATE;

Back to School church Altar Decor
Back to School church Altar Decor

Removing a Column

To remove a column, use the DROP COLUMN syntax. For instance, if you want to remove the 'salary' column from the 'employees' table, you would use:

ALTER TABLE employees DROP COLUMN salary;

Altar Inspiration, Small Altar Ideas, Celtic Altar Ideas, Druid Altar Ideas, Celtic Altar Design, Irish Altar, Celtic Pagan Altar, Celtic Altar Decor, Celtic Altar
Altar Inspiration, Small Altar Ideas, Celtic Altar Ideas, Druid Altar Ideas, Celtic Altar Design, Irish Altar, Celtic Pagan Altar, Celtic Altar Decor, Celtic Altar

Modifying Existing Columns

Often, you might need to modify an existing column, perhaps to change its data type or rename it.

a table with bread and other items on it in front of a cross, potted plants and candles
a table with bread and other items on it in front of a cross, potted plants and candles
a table with bread, grapes and other foods on it in front of a cross
a table with bread, grapes and other foods on it in front of a cross
February Alter table
February Alter table
a table topped with a black cloth covered table
a table topped with a black cloth covered table
two wooden tables sitting next to each other on top of a carpeted floor in front of a white wall
two wooden tables sitting next to each other on top of a carpeted floor in front of a white wall
a desk with many items on it and candles
a desk with many items on it and candles
Proyect "making an altar" for religión class at school. Catholic Mass Preparation Tools, Catholic Portable Altar, Classroom Altar, Traditional Catholic Altar Items, Altar School Project, Altar With Religious Symbols And Decorations, Altar Craft, Simple Religious Altar Setup, Altar Project Ideas
Proyect "making an altar" for religión class at school. Catholic Mass Preparation Tools, Catholic Portable Altar, Classroom Altar, Traditional Catholic Altar Items, Altar School Project, Altar With Religious Symbols And Decorations, Altar Craft, Simple Religious Altar Setup, Altar Project Ideas
the altar has been decorated with handprints and is being displayed in front of a cross
the altar has been decorated with handprints and is being displayed in front of a cross
My 2022 Ostara Alter💐🐇💕
My 2022 Ostara Alter💐🐇💕
Altar And Communion Table Design And Creation | ICS Church Furnishers
Altar And Communion Table Design And Creation | ICS Church Furnishers
Altar
Altar
a table covered in colorful cloths with candles and bread on it at a church
a table covered in colorful cloths with candles and bread on it at a church
witch alter
witch alter
a table topped with a cross, candles and handprints on top of it
a table topped with a cross, candles and handprints on top of it
an open book sitting on top of a table surrounded by lit candles and greenery
an open book sitting on top of a table surrounded by lit candles and greenery
the altar is decorated with red roses and white marble pillars, along with candles on either side
the altar is decorated with red roses and white marble pillars, along with candles on either side
Create Your Simple Witch Altar
Create Your Simple Witch Altar
an antique desk with various items on it
an antique desk with various items on it
a wooden table topped with lots of different types of rocks and glass bottles on top of it
a wooden table topped with lots of different types of rocks and glass bottles on top of it
alter
alter

Changing a Column's Data Type

To change a column's data type, use the CHANGE COLUMN syntax. For example, if you want to change the data type of the 'age' column in the 'employees' table from INT to SMALLINT, you would use:

ALTER TABLE employees CHANGE COLUMN age age SMALLINT;

Renaming a Column

The CHANGE COLUMN syntax can also be used to rename a column. For instance, if you want to rename the 'employee_id' column to 'emp_id' in the 'employees' table, you would use:

ALTER TABLE employees CHANGE COLUMN employee_id emp_id INT;

The ALTER TABLE command is a versatile tool, but it's important to use it with caution. Always remember to back up your data before making structural changes to your tables. Happy modifying!