🛠️ ALTER Command in SQL

Last Updated: January 2026


The ALTER command is a DDL (Data Definition Language) command used to modify the structure of an existing table.

Using ALTER, you can:

  • Add new columns
  • Modify existing columns
  • Rename columns or tables
  • Drop columns

Hinglish Tip 🗣: Table ka structure change karna ho bina delete kiye, tab ALTER command use hota hai.


ADD Column

Adds a new column to an existing table.

-- 1st method
ALTER TABLE table_name
ADD column_name datatype;

-- 2nd method
ALTER TABLE table_name
ADD COLUMN column_name datatype AFTER existing_column_name;
-- 1st method
ALTER TABLE employees
ADD email VARCHAR(100) NOT NULL;

-- 2nd method
ALTER TABLE employees
ADD COLUMN email VARCHAR(100) NOT NULL AFTER emp_name;
  • 1st method: The new column is added at the end of the table.
  • 2nd method: The new column is added after the specified column.

MODIFY / ALTER Column Datatype

Changes the datatype or size of an existing column.

ALTER TABLE table_name
MODIFY column_name new_datatype;
ALTER TABLE employees
MODIFY salary DECIMAL(10,2);

Note : Existing data must be compatible with the new datatype.


RENAME Column

Renames an existing column.

ALTER TABLE table_name
RENAME COLUMN old_name TO new_name;
ALTER TABLE employees
RENAME COLUMN emp_name TO employee_name;

RENAME Table

Renames an existing table.

ALTER TABLE table_name
RENAME TO new_table_name;
ALTER TABLE employees
RENAME TO employee_info;

DROP Column

Purpose

Removes a column permanently.

Syntax

ALTER TABLE table_name
DROP COLUMN column_name;

Example

ALTER TABLE employees
DROP COLUMN email;

Warning: ⚠️ Once dropped, data cannot be recovered.


⚠️ Important Characteristics of ALTER

  • Table data usually remains intact
  • Structure changes are auto-committed
  • Some changes may fail if data conflicts
  • Syntax may vary slightly across DBs