TOP CATEGORIES

×

What is the difference between the drop table and delete table?

S

Sandeep Singh

Difference Between Drop Table and Delete Table

Difference Between Drop Table and Delete Table

There is a very big and very important difference between the drop table and the delete table. Before executing any query you must understand the difference between delete and drop because it can cause loss of your data, so let's understand the difference between them.

Drop-Table

Dropping a table means completely remove the table with its all data and structure, which means the table will be completely removed from the memory along with all data stored in it, you will no longer be able to get data from that table or store new data in the table.

In simple words dropping a table means removing the complete table from the database, it can't be recovered. So next time if you are going to drop a table then think it twice.

Usually, we drop a table in two conditions i.e. we no longer need a table or we want a new table with the same name but a different structure ( columns ). Below I have mentioned the common SQL query to drop a table.

DROP TABLE table_name;

Use drop table very carefully, a dropped table can't be roll-back, so use it carefully.

Delete Table

Delete Table used in many wany, in general, Delete Table deletes records from the table but it does not affect table structure and deleted data can be roll-back using some techniques.

Delete Table used in two ways

  1. To Delete all data from the table.
  2. To Delete certain data from the table based on condition.

Let's Understand the above-listed conditions.

1. Delete all Records

If we want to delete all records from the table then we can simply use the below-given query, it will remove all records from the table but the table structure will remain the same as previous, you will be able to store fresh data in the same table.

DELETE FROM name_table;

2. Delete Certain Records

If you want to remove only a few records (row, column) from the table then you can use this technique. In this technique, the records are deleted based on some conditions by using the where clause. See the below query.

DELETE FROM name_table WHERE col_name=value;

So I hope that you will be able to understand what is a drop table and what is a delete table and the difference between both. Let's take a quick summary of the differences.

  • Drop-Table deleted all table data and table structure.
  • After Dropping Table, The Table and Data can't be roll-backed.
  • Delete Table will delete the data but the Table structure will remain the same.
  • You can Delete specific data from the Table using the where clause.
  • Delete Table can be roll-backed using some techniques.

Thanks...

0 votes

Your Answer

Email: advertise@gdatamart.com

Donate: To Support US

© 2024 GDATAMART.COM (All Rights Reserved)