Junior — Middle
Can you explain what the DELETE operator does in SQL queries?
sobes.tech AI
Answer from AI
The DELETE operator in SQL is used to delete records from a database table.
Syntax:
DELETE FROM table_name WHERE condition;
If the WHERE condition is not specified, all records from the table will be deleted.
Example:
DELETE FROM users WHERE id = 10;
This query will delete the user with id equal to 10.
It is important to use the DELETE operator carefully to avoid deleting unnecessary data. Often, a SELECT with the same condition is performed before deletion to check which records will be affected.