KnowledgeBoat Logo

Computer Science

Differentiate between the following statements:

(i) ALTER and UPDATE

(ii) DELETE and DROP

SQL Queries

1 Like

Answer

(i) Differences between ALTER and UPDATE statements:

ALTER statementUPDATE statement
The ALTER statement is used to modify the structure of database objects, such as tables, views, or schemas.The UPDATE statement is used to modify the existing data in a table.
It can be used to add, modify, or drop columns, constraints, or indexes in a table.It is used to change the values of one or more columns in a table based on specified conditions.
For example: ALTER TABLE Employees ADD Email VARCHAR(255);For example: UPDATE Employees SET Email = 'john.doe@example.com' WHERE EmployeeID = 101;

(ii) Differences between DELETE and DROP statements:

DELETE statementDROP statement
The DELETE statement is used to remove one or more rows from a table based on specified conditions.The DROP statement is used to remove entire database objects, such as tables, views, indexes, or schemas, from the database.
It deletes specific rows of data while keeping the table structure intact.It deletes the entire object along with its structure and data.
For example, DELETE FROM Employees WHERE Department = 'Marketing';For example, DROP TABLE Products;

Answered By

1 Like


Related Questions