Delete a row in SQL | How to delete a row in SQL ?

In my previous articles i have given the idea about multiple types of select statements in SQL with its real life examples.In this article i would like to give you information about delete a row in SQL with examples. Delete a row in SQL is very simple SQL statement but i would like to give multiple real examples so that user will get idea about difference between drop and delete. I would like to give multiple examples of different delete statements to delete a row in SQL.

How to delete a row in SQL?

In this section i will explain different syntax of deleting row in SQL in multiple database management systems.

Oracle / Microsoft SQL :

The user should know the difference between drop and delete statement. The drop table statement will drop the whole table but delete statement will delete the specified data in the table.

Syntax :

Delete from Table_name

Where where_condition_statement;

I would like to explain different scenarios ,

Scenario 1 : Delete the all data in table.

Lets say from Customer table you want to delete whole data from table. The following statement will be useful,

SQL Query :

Delete from Customer;

Scenario 2 :Delete the specific data from table.

Lets say from Customer table user wants to delete a data where customer name is ‘XYZ’.

SQL Query :

Delete from Customer where Customer_Name= ‘XYZ’;

The above query will delete the Customer data where Customer_name is ‘XYZ’.

Scenario 3 : Delete Entire table.

Always user might got confused between deleting the data from table or to drop the entire table from the database.The drop table statement will be used to drop the entire table. If user want to delete table named Customer,

SQL Query :

Drop table Customer;

MySQL Database :

In this section i would like to explain the delete statements in mysql database. The syntax for delete in MySQL is bit different.There is no ‘From’ clause in MySQL database.

Syntax :

Delete tablename;

Scenario 1 : Delete all data from table.

If user wants to delete the all data from customer table in MySQL,

SQL Query :

Delete Customer;

Scenario 2 : Delete specific data from table.

If user wants to delete the data where customer_name is ‘ABC’ in mysql then following statement needs to be used,

SQL Query :

Delete Customer where Customer_Name=’ABC’;

The above statement will delete the data where customer name is ‘ABC’.

I hope you got idea about how to delete a row in SQL with multiple real world industry examples.If you like this article or if you have any issues or concerns with the same kindly comment in to comments section.