September 13, 2024
Delete data in table using SQL
Delete SQL statement is also very important in DML (data manipulation language). We can remove selective or all records from table by using delete SQL statement. By putting condition we can delete partial data from a table which satisfies the condition. And if we need to delete all the record then we can run delete SQL statement without any condition.
1. Delete statement with condition: By adding where condition in delete statement we can delete partial records from a table which matches with the condition. Example is mentioned below:
Example
DELETE FROM student_info WHERE id='1';
DELETE FROM student_info WHERE class_name='3rd';
2. Delete statement without condition: With this approach we can delete all the records present in our table. We do not need to put any condition with our delete SQL statement. Example is mentioned below:
Example
DELETE FROM student_info;