SQL - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Delete

SQL Delete

shape Description

By using SQL DELETE command rows can be deleted from an existing table taking into account the given condition.

shape Conceptual figure

Delete proclamation can be utilized to delete one or more row from a table. Filtering condition can be used for deleting selective data.

shape Syntax

Delete from <table_name> where <condition>;
Table_name => Any accurate table. condition =>condition is a logic to get a specific record.

shape Examples

By viewing the below example, the concept of delete command can be easily understood. [c]sql> select * from employee; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | maddi | 12000 | | 1002 | jack | 13100 | +--------+-------+-------+ 2 rows in set (0.00 sec) sql> delete from employee where ename='maddi'; Query OK, 1 row affected (0.16 sec) sql> select * from employee; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1002 | jack | 13100 | +--------+-------+-------+ 1 row in set (0.00 sec) sql> delete from employee where emp_id=1001; Query OK, 1 row affected (0.16 sec) sql> select * from employee; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1002 | jack | 13100 | +--------+-------+-------+ 1 row in set (0.00 sec)[/c] The above example tells that, when delete command is performed on a table employee and wants to delete ename=maddi, then it delete the entire details of maddi and gives the output of remaining employees in the table.And in another example when delete command is performed on emp_id=1001,then it will delete all the rows of that emp_id like emp_id,ename and salary field names. 

Difference between Truncate and Delete Statements

shape Description

The difference between truncate and delete statements is as follows:

Summary

shape Key Points

  • SQL DELETE - Delete proclamation is utilized to erase a particular column value from the table.