How do you delete a record in a table?
Deleting a record from a table is done with the DELETE command.
Syntax:
sql
DELETE FROM Table_Name
WHERE Condition;Example:
sql
DELETE FROM Employees
WHERE ID = 1;Explanation:
DELETE FROM Employees, picks the table to delete a record from.WHERE ID = 1, specifies the condition for which record to delete (withoutWHERE, every record in the table gets deleted).
Notes
- Using
WHEREis essential when specific records need to be deleted. - Once deleted, a record is irreversibly removed, unless a transaction with
ROLLBACKis used.
Put simply,
DELETEis the SQL command for removing one or several records from a table based on a given condition.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.