Difference between DELETE and TRUNCATE Table

DELETE: DELETE Table is used to delete the rows from the table, It only deletes the rows that are based on the condition given in the where clause or deletes all the rows from the table if no condition is specified. But it does not free the space containing the table. DELETE table syntax logs the deletes thus make the delete operation slow.  

 

1.    To delete a single row with specific ID:

Syntax: DELETE FROM table_name WHERE id = 100;

2.    To delete the all the rows from the table:

Syntax: DELETE FROM table_name;

 

TRUNCATE: TRUNCATE Table is used to delete the entire rows of the table and free the space containing the table. TRUNCATE table cannot trigger and also does not log any information but it logs information about deallocation of data page of the table so TRUNCATE table is faster as compared to delete table.

 

Syntax: TRUNCATE TABLE table_name;

 

Ebook Download
View all
Learn
View all
F11Research & Development, LLC