DELETE Statement in SQL – DML Statements



Now in this SQL Post we will learn Data Manipulation Language (DML) DELETE Statement.

DELETE Statement in SQL – DML Statements


The DELETE Statement – The DELETE Statement is used to delete the records of an existing table.

If we want to delete the rows in a table, we need to use UPDATE query in SQL.

The SQL DELETE Statement Syntax :

DELETE FROM table_name WHERE Condition

table_name – is the name of table which data to be deleted.

In delete Statement we use WHERE  Condition, if we do not use WHERE  condition in delete statement then all the records of table will be deleted. so  it is  good practice to  use where condition while using delete command in sql.

SQL DELETE Statement Example :

For delete some records from an existing table, First we create a new database in database server  and then create a new table in database. After creating a table in database we insert some records using INSERT Statement, after inserting records in a table we apply DELETE query on table to delete records from a table.

We have already learned CREATE Database and CREATE Table and SELECT Statement and INSERT Statement in our previous SQL post.

Now, we have created table named “Student” with some columns like ID, Name, City, Email, Mobile.

Here, we have inserted some records in Student table using  INSERT Statement.

The SQL Student Table :

ID Name City Email
1 Meera Bombay meera@yahoo.com
2 Ram Surat ram@yahoo.com
3 Jay Bombay jay@yahoo.com
4 Vaidehi Ahmedabad meera@yahoo.com

Now, In above Student table we apply DELETE Statement for delete data from table.

The SQL DELETE Statement for Student table.

DELETE FROM Student

Above delete statement delete all records from student table.

If we want to delete records whose id is 3, the SQL Delete Statement is :

DELETE FROM Student WHERE ID=3

The Result of SQL DELETE query :

ID Name City Email
1 Meera Bombay meera@yahoo.com
2 Ram Surat ram@yahoo.com
4 Vaidehi Ahmedabad meera@yahoo.com

I hope you will like this SQL DELETE Statement post…

Leave a Reply

Your email address will not be published. Required fields are marked *