In this tutorial we will learn how to use the SQL DROP and TRUNCATE Commands. These commands can be useful at times, but you MUST be careful with them as you will not get your Data back once you delete it. There is a small difference in the way these two commands work, which is why I am grouping them together.

Step 1. Explanation / Warning

The DROP Command deletes Rows or entire Tables, so you must be careful when you use it. The TRUNCATE Command deletes all of the data out of Tables or Rows, but leaves the Empty Rows there. I take no responsibility if you accidentally delete something important. That being said there are legitimate uses for these Commands and it is important to know how they work in order to prevent yourself from possible SQL injection attacks.

Step 2. Use of Commands

The following is the syntax to use in order to use these commands in SQL.
1. The DROP Command to Drop/Delete a Row

DROP INDEX table_name.index_name

2. The DROP command to Drop/DELETE a Table

DROP TABLE table_name

3. The TRUNCATE command to Delete Data From a Row


4. The DROP Database Function

DROP DATABASE database_name


In this tutorial we learned how to use the Drop and Truncate Commands in SQL. These commands require some careful planning because of the nature of what they do. So use this information carefully and it can help you clean up your databases very quickly.