Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Difference between ALTER and UPDATE Command in SQL

What is ALTER Command?

In SQL, the ALTER command is preferred to rectify, edit or update the attributes of the table. ALTER command is a Data Definition Language command.

Syntax :

To add a column to the existing table

ALTER TABLE tableName

ADD columnName columnDefinition;

What is UPDATE Command?

In SQL, the UPDATE command is used to influence the data of a column. This is a Data Manipulation Language command, so it cannot modify the definition of the table.

Syntax :

For table name that we want to update

UPDATE tableName

For which columns have to update

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

For which row you have to update

WHERE condition

Important: The where clause is mandatory here. Else whole data will get updated.

Difference between ALTER and UPDATE Command in SQL

S.No ALTER Command UPDATE Command
1 It is a Data Definition Language (DDL). It is a Data Manipulation Language (DML).
2 This command operates on the structure level. This command performs on the data level.
3 This command is used to add, remove, and change the details of the tables in a database. It is used to update the details of a table.
4 This command initializes the value of all the tuples as NULL. This command sets fixed values in a tuple.
5 Through this command, we can perform modifications to the table structure. UPDATE command is used to modify the data in the table.

Keep learning and stay tuned to get the latest updates on GATE along with GATE Preparation Books & GATE Answer Key and more.

Also Explore,

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*