SQL DELETE Statement

SQL DELETE statement is used to remove row(s) from a table or view.DELETE Statement

Caution:

This is very common mistake done by database users that they forget to include WHERE condition and all records gets deleted. So while running DELETE command make sure that you are specifying WHERE condition if you want to delete specific records. Also if you want to delete all records from a table then use TRUNCATE TABLE rather than using DELETE command as TRUNCATE table is faster than DELETE and uses lesser resources.

Syntax

DELETE FROM TableName

WHERE condition(s)

In this tutorial, we will use Student table to delete some records.

DELETE

We will try to delete record number 16 from Student table where RollNumber is 8888.

DELETE FROM Student 
WHERE RollNumber = 8888

This query will drop one record from Student table. If you want to delete all records from the table then you can use below query.

DELETE FROM Student 

Reference: Manzoor Siddiqui [www.SQLServerLog.com]

CLICK HERE to watch live practical.

You may also like

You may also like...

Leave a Reply