Delete command in SQL removes the ROW based on the condition provided with the WHERE clause, if no WHERE clause is provided it deletes all the row from the table.
Syntax for delete command:
DELETE FROM table_name WHERE column_name='value';
Truncate command will removes all the rows from the table at one time, and there will be no data left on the table after Truncate command is called.
Syntax for truncate command:
TRUNCATE TABLE table_name;
Some other differences between DELETE and TRUNCATE are:
- DELETE commands removes one row at a time whereas TRUNCATE removes all the rows from the table.
- With DELETE command you can retain Identity counter whereas TRUNCATE resets the Identity counter.
- DELETE command activate triggers whereas TRUNCATE cannot activate triggers
- DELETE is a DML command wheras TRUNCATE is a DDL command.
0 Comment(s)