ALTER TABLE is used to modify the structure of a table that already exists. You can use it to add a new column, drop a column, or change a data type.
Watch out for
On a production database, dropping a column or changing a data type can break existing data and app code. Only do this once you have a backup and a migration plan in place.
sql
-- Add a new column
ALTER TABLE Employees
ADD Email varchar(255);
-- Drop an existing column
ALTER TABLE Employees
DROP COLUMN City;You should see
What this code does: Adds a new Email column to the Employees table and removes the City column. Common mistake: If your app code still references City after you've dropped it, that will cause errors.