Documentation Index
Fetch the complete documentation index at: https://docs.turso.tech/llms.txt
Use this file to discover all available pages before exploring further.
DELETE
TheDELETE statement removes rows from a table.
Syntax
Description
DELETE removes rows that match the WHERE condition. If no WHERE clause is provided, all rows in the table are deleted. The table itself is not removed; use DROP TABLE to remove a table entirely.
WHERE Clause
TheWHERE clause restricts which rows are deleted. Only rows where the expression evaluates to true are removed. Without a WHERE clause, every row in the table is deleted.
RETURNING Clause
TheRETURNING clause causes the DELETE statement to return the values of each deleted row. The result columns can be any expression referencing the deleted row’s columns.
ORDER BY and LIMIT
TheORDER BY and LIMIT clauses restrict which rows are deleted. ORDER BY determines the order in which rows are considered, and LIMIT caps the number of rows that are actually removed. ORDER BY requires LIMIT to be present.
LIMIT accepts an optional OFFSET to skip a number of rows before applying the limit:
ORDER BY without LIMIT is not allowed on DELETE statements. If you need to delete all rows matching a condition in a specific order, provide a LIMIT value larger than the expected number of matching rows.Examples
Delete rows matching a condition
Delete with RETURNING
Delete the oldest rows with ORDER BY and LIMIT
See Also
- UPDATE for modifying existing rows
- INSERT for adding new rows
- DROP TABLE for removing an entire table
- SELECT for querying data