What is the purpose of the DELETE statement in MySQL?
A
To remove a column from a table B
To delete all records from a table C
To update records in a table D
To drop a database
Analysis & Theory
The DELETE statement is used to remove one or more rows from a table.
What will happen if you run `DELETE FROM users;` without a WHERE clause?
A
Only the first row is deleted B
An error is thrown C
All rows in the `users` table are deleted D
Nothing happens
Analysis & Theory
Without a WHERE clause, DELETE removes all rows from the table.
Which clause is used in a DELETE statement to delete specific records?
A
SET B
HAVING C
WHERE D
ORDER
Analysis & Theory
The WHERE clause is used to filter which records should be deleted.
What is the correct syntax to delete a user with id 10 from a `users` table?
A
DELETE id = 10 FROM users; B
REMOVE FROM users WHERE id = 10; C
DELETE FROM users WHERE id = 10; D
DELETE * FROM users WHERE id = 10;
Analysis & Theory
The correct syntax is: DELETE FROM users WHERE id = 10;
How do you delete all records from a table but keep its structure?
A
DELETE * FROM table; B
TRUNCATE DATABASE table; C
DROP table; D
DELETE FROM table;
Analysis & Theory
DELETE FROM table; removes all data but keeps the table and its structure.
Which SQL statement removes both the data and the table structure?
A
DELETE B
TRUNCATE C
DROP D
CLEAR
Analysis & Theory
DROP removes the table entirely, including its structure and all its data.
What is the difference between DELETE and TRUNCATE in MySQL?
A
DELETE is faster than TRUNCATE B
DELETE removes table structure too C
TRUNCATE is a DML command D
DELETE can use WHERE clause, TRUNCATE cannot
Analysis & Theory
DELETE can delete specific rows using WHERE; TRUNCATE deletes all rows without WHERE support.
Which keyword ensures that only one record is deleted from a table?
A
ORDER BY B
WHERE C
LIMIT D
TOP
Analysis & Theory
The LIMIT clause restricts the number of rows affected by DELETE.
What does this query do?
`DELETE FROM orders WHERE status = 'cancelled';`
A
Deletes orders that are not cancelled B
Deletes all orders C
Deletes only cancelled orders D
Deletes the orders table
Analysis & Theory
It deletes rows from the `orders` table where the status is 'cancelled'.
Which clause should always be used with DELETE to prevent accidental data loss?
A
ORDER BY B
SET C
WHERE D
SELECT
Analysis & Theory
Using a WHERE clause prevents the DELETE statement from removing all records.