Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
SQL ALTER TABLE

SQL ALTER TABLE: A Comprehensive Guide

Posted on January 16, 2025January 16, 2025 By Rishabh saini No Comments on SQL ALTER TABLE: A Comprehensive Guide

SQL ALTER TABLE

The ALTER TABLE statement in SQL is a powerful command that allows you to modify an existing table without the need to recreate it. With this statement, you can add, modify, or delete columns and even update the constraints applied to a table. Additionally, it enables you to rename columns or the table itself. Let’s dive deeper into the various functionalities of the ALTER TABLE statement.

Complete Advance AI topics:- CLICK HERE
Complete Python Course with Advance topics:-Click here

Adding Columns Using ALTER TABLE

In real-world scenarios, you may need to add new columns to an existing table to store additional data. The ALTER TABLE statement with the ADD keyword makes this process seamless.

Syntax for Adding a Single Column

ALTER TABLE table_name ADD column_name column_definition;

This syntax is used to add a single column to an existing table.

Syntax for Adding Multiple Columns

ALTER TABLE table_name
ADD (
    column_name1 column_definition,
    column_name2 column_definition,
    ...
    column_nameN column_definition
);

This syntax allows you to add multiple columns in a single query.

Examples

Example 1: Adding a Single Column

Consider a table named Cars:

Car NameCar ColorCar Cost
Hyundai CretaWhite10,85,000
Hyundai VenueWhite9,50,000
Hyundai i20Red9,00,000
Kia SonetWhite10,00,000
Kia SeltosBlack8,00,000
Swift DezireRed7,95,000

To add a new column Car_Model, use the following query:

ALTER TABLE Cars ADD Car_Model VARCHAR(20);

This adds the Car_Model column to the Cars table.

Example 2: Adding Multiple Columns

Consider a table named Employee:

Emp_IdEmp_NameEmp_SalaryEmp_City
201Abhay25000Goa
202Ankit45000Delhi
203Bheem30000Goa
204Ram29000Goa
205Sumit40000Delhi

To add two columns, Emp_ContactNo and Emp_EmailID, use this query:

ALTER TABLE Employee ADD (
    Emp_ContactNo NUMBER(13),
    Emp_EmailID VARCHAR(50)
);

Modifying Columns Using ALTER TABLE

The MODIFY keyword is used to alter the definition of an existing column, such as changing its data type.

Syntax for Modifying a Single Column

ALTER TABLE table_name MODIFY column_name column_definition;

Syntax for Modifying Multiple Columns

ALTER TABLE table_name
MODIFY (
    column_name1 column_definition,
    column_name2 column_definition,
    ...
    column_nameN column_definition
);

Examples

Example 1: Modifying a Single Column

To change the data type of the Car_Color column in the Cars table:

ALTER TABLE Cars MODIFY Car_Color VARCHAR(50);

Example 2: Modifying Multiple Columns

To update the data types of Emp_ContactNo and Emp_EmailID in the Employee table:

ALTER TABLE Employee MODIFY (
    Emp_ContactNo INT,
    Emp_EmailID VARCHAR(80)
);

Deleting Columns Using ALTER TABLE

When a column is no longer needed, it can be removed using the DROP keyword.

Syntax for Deleting a Column

ALTER TABLE table_name DROP COLUMN column_name;

Examples

Example 1: Deleting a Single Column

To delete the Car_Color column from the Cars table:

ALTER TABLE Cars DROP COLUMN Car_Color;

This removes the Car_Color column from the table.

Example 2: Deleting Multiple Columns

To delete the Emp_Salary and Emp_City columns from the Employee table, use two queries:

ALTER TABLE Employee DROP COLUMN Emp_Salary;
ALTER TABLE Employee DROP COLUMN Emp_City;

Renaming Columns Using ALTER TABLE

The RENAME COLUMN clause is used to rename a column in an existing table.

Syntax for Renaming a Column

ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;

Examples

Example 1: Renaming a Column in the Cars Table

To rename the Car_Color column to Colors:

ALTER TABLE Cars RENAME COLUMN Car_Color TO Colors;

Example 2: Renaming a Column in the Employee Table

To rename the Emp_City column to Emp_Address:

ALTER TABLE Employee RENAME COLUMN Emp_City TO Emp_Address;

Summary

The ALTER TABLE statement is a versatile tool for managing and modifying the structure of existing tables in SQL. Whether you need to add new columns, update their definitions, remove unnecessary ones, or rename them for clarity, the ALTER TABLE statement simplifies these tasks. Mastering this command is essential for efficient database management.

Download New Real Time Projects :-Click here


sql alter table add column
sql update
sql alter table add multiple columns
sql alter table
sql alter table add column
oracle sql alter table add column
oracle sql alter table
sql alter table drop column
sql alter table column size
sql alter table add multiple columns
sql alter table alter column
sql alter table name

Post Views: 761
SQL Tutorial Tags:add column in a table in sql, advanced sql tutorials, alter table command in sql, computer science, computing, data definition language, database, ddl, drop column in a table in sql, microsoft sql server tutorial, modify columns in sql tables, mysql tutorial, oracle database (software), oracle tutorial, Programming, relational database management system, sql, sql (programming language), sql tutorial for beginners, structured query language, table, tutorial (industry)

Post navigation

Previous Post: Task Management System Using Spring Boot
Next Post: Real-Time Emotion Detection with Python

More Related Articles

SQL FULL JOIN SQL FULL JOIN – A Complete Guide SQL Tutorial
SQL SELECT TOP SQL SELECT TOP Clause: A Comprehensive Guide SQL Tutorial
SQL SELECT NULL SQL SELECT NULL SQL Tutorial

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Understanding the SQL DELETE Statement and Its Variants
  2. SQL Temporary Tables: A Handy Tool for Developers
  3. SQL WITH Clause
  4. SQL UPDATE with JOIN
  5. Understanding SQL CROSS JOIN with Examples
  6. IN vs EXISTS in SQL: A Complete Guide

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Blog Site In PHP And MYSQL With Source Code || Best Project
  9. Online Bike Rental Management System Using PHP and MySQL
  10. E learning Website in php with Free source code
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Agentic RAG AI System Using Python – Complete Final Year Project Guide
  • AI-Powered Online Examination System with Face Detection Using PHP & MySQL
  • Real-Time Medical Queue & Appointment System with Django
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital

Most Viewed Posts

  • Top Large Language Models in 2025 (8,630)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,248)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,911)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme