SQL Delete Command
Delete command is used to delete the record from the table.
- Using Delete command you can delete all the records from the table without delete table.
- Using Delete command you can delete specific records from the table "using where clause"
Syntax
DELETE FROM table_name
WHERE some_column=some_value;
Employee table
| emp_id | name | salary |
| 101 | Amit | 24000 |
| 102 | Rahul | 34000 |
| 103 | Sultan | 54000 |
| 104 | Gaurav | 26000 |
| 105 | Hitesh | 35000 |
Example
DELETE FROM Employee
WHERE salary<30000;
Result after Execute above query.
| emp_id | name | salary |
| 102 | Rahul | 34000 |
| 103 | Sultan | 54000 |
| 105 | Hitesh | 35000 |
Difference between truncate and delete
| Truncate | Delete |
| 1 | It is DDL Command | It is DML Command |
| 2 | It is used for permanent deletion. | It is used for temporary deletion. |
| 3 | We can not delete the specific record. | We can delete the specific records. |
Delete all record
You can also delete all the record from a table without deleting table.
Syntax
DELETE FROM table_name
or
DELETE * FROM table_name;
Example
DELETE FROM Employee
Comments
Post a Comment