Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
Difference Between Alias and Synonym in SQL
Next article icon

Difference between ALTER and UPDATE Command in SQL

Last Updated : 11 Apr, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

1. ALTER Command:

ALTER SQL command is a DDL (Data Definition Language) statement. ALTER is used to update the structure of the table in the database (like add, delete, modify the attributes of the tables in the database).

Syntax:

// add a column to the existing table  ALTER TABLE tableName  ADD columnName columnDefinition;     // drop a column from the existing table  ALTER TABLE tableName  DROP COLUMN columnName;    // rename a column in the existing table  ALTER TABLE tableName  RENAME COLUMN olderName TO newName;    // modify the datatype of an already existing column in the table  ALTER TABLE table_name  ALTER COLUMN column_name column_type;

2. UPDATE Command:

UPDATE SQL command is a DML (Data manipulation Language) statement. It is used to manipulate the data of any existing column. But can’t be change the table’s definition.

Syntax:

// table name that has to update  UPDATE tableName  // which columns have to update  SET column1 = value1, column2 = value2, ...,columnN=valueN.  // which row you have to update  WHERE condition

Note :  Without WHERE clause, all records in the table will be updated.

Difference Between ALTER and UPDATE Command in SQL: 

SR.NO ALTER Command UPDATE Command
1 ALTER command is Data Definition Language (DDL). UPDATE Command is a Data Manipulation Language (DML).
2 Alter command will perform the action on structure level and not on the data level. Update command will perform on the data level.
3 ALTER Command is used to add, delete, modify the attributes of the relations (tables) in the database. UPDATE Command is used to update existing records in a database.
4 ALTER Command by default initializes values of all the tuple as NULL. UPDATE Command sets specified values in the command to the tuples.
5 This command make changes with table structure. This command makes changes with data inside the table.
6 It works on the attributes of a relation. It works on the attribute of a particular tuple in a table. 
7 Example : Table structure, Table Name, SP, functions etc. Example : Change data in the table in rows or in column etc.
8

Syntax with Example

Syntax:

ALTER TABLE tableName

DROP COLUMN columnName;

Example:

ALTER TABLE Students
DROP COLUMN Address;
 

Syntax with Example

Syntax:

UPDATE tableName

SET column1 = value1, column2 = value2, ..,columnN = valueN.

WHERE condition

Example:

UPDATE Students
SET Name = ‘SAM’, City= ‘GREEN’
WHERE StudentID = 10;

The Alter statement is is used when we needs to change something in table or modify the table whereas the Update statement is used when user wants to modify something in data which is stored in the table. We can say that Alter works with table structure of the table and Update works with data within the table.  

 



Next Article
Difference Between Alias and Synonym in SQL

A

adware
Improve
Article Tags :
  • DBMS
  • Difference Between
  • SQL
  • DBMS-SQL
  • SQL-basics

Similar Reads

  • Difference between View and Cursor in SQL
    1. View : A view is a virtual table that not actually exist in the database but it can be produced upon request by a particular user. A view is an object that gives the user a logical view of data from a base table we can restrict to what user can view by allowing them to see an only necessary colum
    3 min read
  • Difference between DROP and TRUNCATE in SQL
    In SQL, the DROP and TRUNCATE commands are used to remove data, but they operate differently. DROP deletes an entire table and its structure, while TRUNCATE removing only the table data. Understanding their differences is important for effective database management. In this article, We will learn ab
    3 min read
  • Difference Between COMMIT and ROLLBACK in SQL
    In SQL, transaction control is essential for managing changes in a database effectively. COMMIT and ROLLBACK are two crucial Transaction Control Language (TCL) commands that help maintain data integrity and consistency. While COMMIT ensures that all changes in a transaction are permanently saved, RO
    4 min read
  • Difference between SQL and T-SQL
    SQL (Structured Query Language) is the standard language for managing and manipulating relational databases, enabling operations like querying, updating, and deleting data. T-SQL (Transact-SQL), an extension of SQL developed by Microsoft, adds advanced features and procedural capabilities specifical
    4 min read
  • Difference Between Alias and Synonym in SQL
    In SQL, two keywords are used to create an alternative name which are alias and synonym. Although both of these have similar functions, each of these keywords has its purpose. This means that the Alias has different usage from Synonym and vice versa. In this article, we will explain the key differen
    4 min read
  • Difference between From and Where Clause in SQL
    1. FROM Clause: It is used to select the dataset which will be manipulated using Select, Update or Delete command.It is used in conjunction with SQL statements to manipulate dataset from source table.We can use subqueries in FROM clause to retrieve dataset from table. Syntax of FROM clause: SELECT *
    2 min read
  • Difference between DBMS and SQL
    1. Database management system (DBMS) :Database management system (DBMS) is a software that manage or organize the data in a database. We can arrange the data in a tabular form (i.e. in row or column). It helps the user to retrieve the data from the database.Best examples of DBMS are - MYSQL, ORACLE,
    2 min read
  • Differences between SQL and SQLite
    1. Structured Query Language (SQL) : SQL stands for Structured Query Language. SQL can access, created and manage databases. SQL has became standard of American National Standards Institute. 2. SQLite : SQLite is software which provides relational database management system. SQLite lightweight in te
    2 min read
  • Difference Between DELETE and DROP in SQL
    In SQL, the DELETE and DROP commands are essential for managing data in a database, but they serve different purposes. While both are used to remove data, their functionality varies significantly. The DELETE command is designed to remove specific rows (tuples) or all rows from a table while preservi
    4 min read
  • Difference between T-SQL and PL-SQL
    1. Transact SQL (T-SQL) : T-SQL is an abbreviation for Transact Structure Query Language. It is a product by Microsoft and is an extension of SQL Language which is used to interact with relational databases. It is considered to perform best with Microsoft SQL servers. T-SQL statements are used to pe
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences