Can a where Clause be used along with a Truncate command


Every SQL Developer wants full control over the Database by query. Due to which they start thinking beyond the SQL syntax. One such misconception is whether a where Clause be used along with a Truncate command to perform some conditional operations.

For example, if someone wants to delete all records of last week (7 days) using Truncate command. Although this can be done using "Delete from table_name where conditions" but truncate is used because it is faster than Delete query.

The Answer for the question "Can a where Clause be used along with a Truncate command" is NO. Truncate statement means All or Nothing. This means either all the records in the Table will be deleted or none of them will be deleted.

What does TRUNCATE TABLE mean?

TRUNCATE TABLE is a statement in SQL that deletes all records in a table very fast by deallocating the data pages used by the table. Deallocating the data pages reduces the resource overhead of logging the deletions done, as well as the number of locks acquired. Records removed by the TRUNCATE TABLE query statement cannot be restored, so you need to be very careful before executing TRUNCATE TABLE query.




For any inquiry, Contact us at

Facing Programming Errors. Get Answers within 24 hours:

Recommendation Based on your Interest

Quiz For You:
Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Search Tags