DELETE and TRUNCATE are both used to delete data from a table, but the way they do it is different.

DELETE is a DML (Data Manipulation Language) command that allows you to remove records from a table one row at a time. It can be used with a WHERE clause to delete only certain rows.

Example:
DELETE FROM my_table WHERE id = 5;

TRUNCATE is a DDL (Data Definition Language) command that allows you to delete all the records from a table in one go. It is faster than DELETE since it does not generate any undo or rollback information.

Example:
TRUNCATE TABLE my_table;

Leave a Reply

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