ALTER TABLE is a Data Definition Language (DDL) command used to change the structure of an existing table. It allows you to add new columns, modify existing columns, rename columns, or remove columns without recreating the table.
Business requirements change over time. New columns may need to be added, data types modified, or unnecessary columns removed without affecting the existing data.
A company decides to store employee email addresses. Instead of creating a new table, the existing Employees table is modified by adding an Email column.
ALTER TABLE Employees
ADD Email VARCHAR(100);
ALTER TABLE is frequently used when applications introduce new features, require additional information, or need to improve the database structure.
- Modifies an existing table.
- Can add new columns.
- Can modify existing columns.
- Can remove unnecessary columns.
- Preserves existing table data.
- Supports multiple structural changes.
- It is a DDL command.
Which SQL statement is used to change a table structure?
ALTER TABLE is used to modify the structure of an existing table.
Can ALTER TABLE add new columns?
Yes. It can add one or more new columns to an existing table.