Truncate
and Delete
are the two commands used to delete a table’s data in SQL. Both of these commands are used for the same purpose, but there is still a slight difference between them.
Truncate | Delete |
---|---|
Truncate typically resets the identity of a particular table. |
Delete only deletes the data and does not reset the identity of the table. |
Truncate comes with the word TABLE . |
Delete comes with the word FROM . |
Truncate is a data definition language (DDL) command. |
Delete is a data manipulation language (DML) command. |
Truncate does not maintain a log; hence, it is fast. |
Delete maintains a log; hence, it is slow. |
Suppose that the table Educative
needs to be deleted from the SQL.
Truncate TABLE Educative
Delete FROM Educative
Free Resources