Get Started: SQL DELETE Statement

In This Article, You Will Know About SQL DELETE Statement. 

SQL DELETE Statement– Before moving ahead, let’s know a bit about SQL Null Values.

Table of Contents

DELETE Statement

The DELETE statement is used to delete or erase existing records in SQL.

DELETE Syntax

				
					DELETE FROM table_name WHERE condition;
				
			

Note: While using the “DELETE” statement, the “WHERE” statement defines which record has to delete if we forget to mention the “WHERE” statement while deleting records, then it will delete all records.

Example Database

Below is the example of a database table named “details.”

Id

Name

Class

section_id

1

Alex

5

1

2

Rolex

6

2

3

Salex

7

2

4

Lelex

8

3

5

Kelex

9

5

DELETE Statement Example

Example: Use the DELETE statement to delete the record from the table.

				
					DELETE FROM details WHERE Id = 4;
				
			

As a result, it returns the table after deleted row Id = 4.

Example: Use the DELETE statement to delete the record from the table.

				
					DELETE FROM details WHERE Name = 'Rolex';
				
			

As a result, it returns the table after deleted Name = ‘Rolex’.

DELETE All Records

It is possible to delete all records in the table, we just need not use the “WHERE” statement.

				
					DELETE FROM details
				
			

As a result, it deleted the whole table.

If you find anything incorrect in the above-discussed topic and have further questions, please comment below.

Connect on:

1 thought on “Get Started: SQL DELETE Statement”

Leave a Comment

Stay in the loop

codingstreets