Computer Science, asked by vanshikamittal12319, 3 months ago

Differentiate between Alter and update command. Explain with an example.​

Answers

Answered by jainsuparshav
11

Explanation:

ALTER is used to update the structure of the table (add/remove field/index etc). Whereas UPDATE is used to update data. The ALTER changes the table in the database, you can add or remove columns, etc. ... While the UPDATE changes the rows in the table, and leaves the table unchanged.

Answered by palsabita1957
9

The ALTER command is a DDL [Data Definition Language] command while the UPDATE command is a DML [Data Manipulation Language] command.

The ALTER command is used to make modifications relating to the structure/definition of the table while the UPDATE command is used to make modifications relating to the data/records in the table.

An example of both their usages   :-

ALTER TABLE Movies ADD(Rating int(5)); will add a column named 'Rating' to the table names 'Movies'.

UPDATE Movies SET MName = 'The Bourne Identity' WHERE Rating = 4; will change the movie name to 'The Bourne Identity' where the rating is 4 in the table named 'Movies'.

Similar questions