Difference Between ALTER and UPDATE in database ?

Difference Between ALTER and UPDATE in database ?

ALTER is a DDL (Data Definition Language) statement. Whereas UPDATE is a DML (Data Manipulation Language) statement. ALTER is used to update the structure of the table (add/remove field/index etc). Whereas UPDATE is used to update data.

Example of ALTER:

ALTER TABLE Persons
ADD PRIMARY KEY (P_Id)

Example of UPDATE:

UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;

Leave a Reply

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