3.SQL DELETE Statement


The SQL DELETE Statement

The DELETE statement is used to delete existing records in a table.

DELETE Syntax

DELETE FROM table_name WHERE condition;


Demo Database

Below is a selection from the "Customers" table in the Northwind sample database:

CustomerIDCustomerName

CityPostalCodeCountry
1

Jamdhade Tushar

Newasa12209India
2Jamdhade Atharv

Shrirampur05021India
3Jamdhade Sagar

Pune05023India
4

Jamdhade Gaurav

MumbaiWA1 1DPIndia
5Jamdhade Tush

DeliS-958 22India

SQL DELETE Example

The following SQL statement deletes the customer "Alfreds Futterkiste" from the "Customers" table:

Example

DELETE FROM Customers WHERE CustomerName='Jamdhade Tushar';


The "Customers" table will now look like this:

CustomerIDCustomerName

CityPostalCodeCountry
2Jamdhade Atharv

Shrirampur05021Mexico
3Jamdhade Sagar

Pune05023Mexico
4
Jamdhade Gaurav

MumbaiWA1 1DPUK
5Jamdhade Tush

DeliS-958 22Sweden

Delete All Records

It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:

DELETE FROM table_name;

The following SQL statement deletes all rows in the "Customers" table, without deleting the table:

Example

DELETE FROM Customers;








Post a Comment

Previous Post Next Post