DELETE vs. DROP vs. TRUNCATE

Chloooo
3 min readAug 4, 2020

The Elegant Way of Deletion In Database

Photo by Javier Allegue Barros on Unsplash

Manipulating with data is common for IT professionals including database administrators, developers, data analysts and scientists, and playing with data in database is simple and straight forward. SQL is a specialized language for database operations and is very easy to understand and use. Unlike C or any other object-oriented programming, we try not to write SQL logics or function blocks except for built-in logics working with applications. We usually don’t define variables, and we try to avoid looping at all costs. For example, if I want to retrieve some data, I simply type in SELECT .. FROM .. , and if I want to restrict the number of records returned, I can add in WHERE .. or LIMIT .. clause.

Every IT practitioner may have worked with databases, however the level of expertise requirements for different roles are different. The same task can be done using different method to achieve the same data result but perform differently underneath.

In this article, I will discuss one common case every IT practitioner may be familiar with: remove data in database.

When deleting some data, what comes to our mind first? Probably DELETE.

DELETE command is used for deleting a row in table, and it can be rolled back before commit. We can either delete rows with…

--

--