Updated: May 22, 2020
Truncate: TRUNCATE SQL query removes all rows from a table, without logging the individual row deletions. TRUNCATE is faster than the DELETE query.
TRUNCATE TABLE TABLE_NAME
DDL (Data Definition Langauge)
Can not use where clause
Drop the table and recreates it.
Truncate removes all rows from the table.
Delete: SQL DELETE query deletes all records from a database table. To execute a DELETE query, delete permissions are required on the target table. If you need to use a WHERE clause in a DELETE, select permissions are required as well.
DELETE FROM Table_Name;
DELETE FROM Customers WHERE OrderId > 1000;
DML (Data Manipulation Language)
Where clause can be used
Delete the rows one by one
Triggers can be used
The DELETE statement removes rows one at a time and records an entry in the transaction log for each deleted row.
DROP: DROP table query removes one or more table definitions and all data, indexes, triggers, constraints, and permission specifications for those tables. DROP command requires to ALTER permission on the schema to which the table belongs, CONTROL permission on the table, or membership in the db_ddladmin fixed database role.
DROP TABLE Table_Name
The DROP command removes a table from the database.
All the tables' rows, indexes, and privileges will also be removed.
No DML triggers will be fired.
The operation cannot be rolled back.
DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command.
DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Follow Programmers Door for more.