Syntax
Parameters
The
DELETE FROM <table> without <expression> will delete all rows from the table. It is equivalent to a TRUNCATE TABLE statement.Remarks
Deleted rows are marked for deletion, but are not automatically cleaned up. You can monitor fragmentation in information_schema.tables to understand how many rows are marked for deletion out of total rows; fragmentation = (rows marked for deletion / total rows). Total row count ininformation_schema.tables excludes the number of rows marked for deletion. Query performance is not materially impacted by delete marks.
To mitigate fragmentation, use the VACUUM command to manually clean up deleted rows.
Example
The following example deletes entries from theproducts table where the quantity is less than 10:
Table after:
Example specifying other tables in the USING clause
This example deletes all the products from stores that went out of business.products before:
Table
suppliers before:
Table
products after: