Junior — Middle
Explain what a SQL DELETE operation is and how it is used to delete data.
sobes.tech AI
Answer from AI
The SQL operation DELETE is used to remove one or more records from a database table.
Syntax:
DELETE FROM table_name WHERE condition;
WHEREspecifies which records will be deleted. IfWHEREis omitted, all records from the table will be deleted.
Example: delete all users older than 30 years
DELETE FROM users WHERE age > 30;
It is important to use WHERE to avoid accidentally deleting all data. After executing DELETE, records are irreversibly removed (unless recovery is configured).
In testing and automation QA, the DELETE operation is checked to ensure that deletion occurs correctly and does not affect data integrity.