What is the difference between DELETE and TRUNCATE statements?

Asked: Apr 14, 2023

DELETE -

Delete command is used to delete a row in a table.

You can Rollback data after using delete statements.

It is a DML (Data Manipulation Language) command.

It is slower than a truncated statement.

DELETE FROM TableName WHERE condition;

Truncate - 

Truncate is used to delete all the rows from a table.

You can not rollback data.

It is DDL (Data Definition Language) command

It is Faster

TRUNCATE TABLE TableName;

 

 

No.

DELETE

TRUNCATE

1)

The delete statement removes single or multiple rows from an existing table depending on the specified condition.

The truncate command deletes the whole contents of an existing table without the table itself. It preserves the table structure or schema.

2)

DELETE is a DML command.

TRUNCATE is a DML command.

3)

We can use the WHERE clause in the DELETE command.

We cannot use the WHERE clause with TRUNCATE.

4)

DELETE statement is used to delete a row from a table.

TRUNCATE statement is used to remove all the rows from a table.

5)

DELETE is slower because it maintained the log.

TRUNCATE statement is faster than DELETE statement as it deletes entire data at a time without maintaining transaction logs.

6)

You can roll back data after using the DELETE statement.

It is not possible to roll back after using the TRUNCATE statement.

7)

DELETE query takes more space.

TRUNCATE query occupies less space.

Asked by brijesh

Answers (0)

No answers yet. Be the first to answer!