Categories: SQL Tutorials

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.

Amit S

Oracle Consultant with vast experience in Oracle BI and PL/SQL Development. Amiet is the admin head of this website who contributes by preparing tutorials and articles related to database technologies. He is responsible to manage the content and front-end of the website.

Recent Posts

The Essential Guide to Cryptocurrency Exchange Platform Development for Beginners and Beyond

Introduction Cryptocurrencies took the world by storm, setting up a new financial system and breaking…

5 months ago

Top 20 System Administrator Interview Questions and answers

In my previous article I have given Top 20 technical support interview questions with its…

8 months ago

Desktop Support Scenario Based Interview Questions

In my previous articles I have given 15 most asked desktop support interview questions with…

8 months ago

How Do Business Analysts Use SQL for Their Needs?

A business analyst is someone who is versed in processes of data analysis used for…

8 months ago

Top 15 Control-M Interview Questions with Answers

In my previous article I have already given top questions and answers for Desktop support…

8 months ago

Top 20 SQL Interview Questions for Production Support

In my previous article I have given unix production support interview questions and answers. In…

8 months ago