DELETE Statement in SQL

In SQL, DELETE statement in SQL is used to Delete the records or data present in the table.
Using DELETE statement, We can Delete the specific data or the whole table data. Here point to note, DELETE statement deletes the data only, it will leave the table structure identical.

SQL Syntax :

SQL > DELETE FROM table_name
WHERE some_column=some_value;

 

Delete Statement in SQL with Example

The SQL DELETE command is used to delete rows or records from a table. In the below example, We are deleting all records from Departments table.

SQL > DELETE from Departments ; 

 

Example – Delete all records from Employee table, which have the department Id 101.

SQL > DELETE from Employees

          Where department_id = 101;

 

Delete Records using Comparison Operators

In this tutorial, we will see, how the COMPARISON operator along with SQL DELETEcommand can be used to remove specific rows from a table.

SQL> DELETE FROM Customer  

         WHERE cust_country =’United Kingdom’  AND cust_city <>’London’ ;

 

Delete Records using IN Operator

In below example, We will see, how the SQL IN operator along with SQL DELETE command can be used to remove specific rows from a table.

SQL > DELETE FROM Orders 

          WHERE advance_amount  NOT IN (1000,2000) ;

 

 

Delete Records using LIKE Operator

In below example, We will see, how the SQL LIKE operator along with SQL DELETE command can be used to remove specific rows from a table.

SQL > DELETE FROM customer  

           WHERE cust_city  LIKE ‘M%’; 

 

0 Comment

Leave a Reply