Difference between TRUNCATE, DELETE and DROP in SQL Server: In this post, we are sharing about one of the important interview questions which are asked in every interview. So we are trying to explain in simple words so that everyone can easily understand and get an idea about. Oracle database pl/sql sql DBA script, unix, shell script, Tips IT, Programming Home Oracle DBA & All IT » Function, Oracle Tips, Tuning Performance » ความแตกต่างระหว่างคำสั่ง Truncate, Delete และ Drop. Differences between the SQL Server DELETE and TRUNCATE Commands. Truncate reseeds identity values, whereas delete doesn't. Truncate removes all records and doesn't fire triggers. Truncate is faster compared to delete as it makes less use of the transaction log. A DELETE statement willl log the deletion of each row in the transaction log wherease TRUNCATE will just log the deallocation of the pages the data is on. TRUNCATE uses less resources so you will often see a massive speed difference in removing rows, particuarly with large tables.
- Truncate Delete Compare
- Delete Drop Truncate Difference In Sql Syntax
- Delete Drop Truncate Difference In Sql
What is the difference between TRUNCATE, DELETE and DROP statements?
In this blog, we will learn the difference between TRUNCATE, DELETE, and DROP statements that are mostly used interchangeably but are totally different. So, let's get started.
TRUNCATE
TRUNCATE Command is a Data Definition Language operation. It is used to remove all the records from a table. It deletes all the records from an existing table but not the table itself. The structure or schema of the table is preserved.
Truncate Delete Compare
Truncate command marks the table for deallocation. This operation removes all the data from a table bypassing a number of constraints enforced on the table. MySQL does not allow the users to truncate the table which is referenced as FOREIGN KEY in another table.
TRUNCATE TABLE statement is a DDL command so it can not be rolled back.
The Truncate command resets the AUTO_INCREMENT counters on the table.
Delete Drop Truncate Difference In Sql Syntax
MySQL truncates the table by dropping and creating the table. Thus, the DELETE triggers for the table do not fire during the truncation.
Syntax
The syntax for the TRUNCATE TABLE statement in MySQL is:
For example:
Truncate statement is equivalent to DELETE operation without a WHERE clause. The truncate command removes the records from a table without scanning it. This is why it is faster than the DELETE statement.
DELETE
The DELETE statement in SQL is a Data Manipulation Language(DML) Command. It is used to delete existing records from an existing table. We can delete a single record or multiple records depending on the condition specified in the query.
The conditions are specified in the WHERE clause of the DELETE statement. If we omit the WHERE clause then all of the records will be deleted and the table will be empty.
The DELETE statement scans every row before deleting it. Thus it is slower as compared to TRUNCATE command. If we want to delete all the records of a table, it is preferable to use TRUNCATE in place of DELETE as the former is faster than the latter.
DELETE is a DML Command so it can be rolled back.
The DELETE command returns the number of records that were deleted by its execution.
Syntax
The syntax for the DELETE statement in SQL is:
We do not need to list fields in the DELETE statement since we are deleting the entire row from the table.
For example:
DROP
DROP statement is a Data Definition Language(DDL) Command which is used to delete existing database objects. It can be used to delete databases, tables, views, triggers, etc.
A DROP statement in SQL removes a component from a relational database management system (RDBMS).
DROP is a DDL Command. Objects deleted using DROP are permanently lost and it cannot be rolled back.
Unlike TRUNCATE which only deletes the data of the tables, the DROP command deletes the data of the table as well as removes the entire schema/structure of the table from the database.

Syntax
For example:
DROP Command removes the table definition and all the data, indexes, triggers, constraints and permission specifications for that table.
That's it for this blog. Hope you learned something new today.
Do share this blog with your friends to spread the knowledge. Visit our YouTube channel for more content. You can read more blogs from here.
Keep Learning :)
Delete Drop Truncate Difference In Sql
Team AfterAcademy!