• iconteach@devfunda.com

Alter Table

Alter Table

31-08-2025 08:57:51 Time to read : 12 Minutes

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. This is what you’ll use when the table structure needs changes after it has already been created.
You can:

  1. Add new columns
  2. Rename columns
  3. Change column data types
  4. Drop (remove) columns
  5. Add or remove constraints

Add a New Column
Adds a new column phone to the students table.


ALTER TABLE students 
ADD COLUMN phone VARCHAR(15);

Rename a Column
Changes column name to full_name.

ALTER TABLE students 
RENAME COLUMN name TO full_name;

Change Data Type
Changes the data type of age from INT to SMALLINT.

ALTER TABLE students 
ALTER COLUMN age TYPE SMALLINT;

Drop (Remove) a Column
Removes the email column.


ALTER TABLE students 
DROP COLUMN email;

Rename the Table
Renames the whole table to learners.


ALTER TABLE students 
RENAME TO learners;

 

Want to learn in class